diff options
| author | syuilo <syuilotan@yahoo.co.jp> | 2017-02-12 06:00:40 +0900 |
|---|---|---|
| committer | syuilo <syuilotan@yahoo.co.jp> | 2017-02-12 06:00:40 +0900 |
| commit | a6ce54ec1818e5f1dc0b1a600aa1ddd3ee48b90e (patch) | |
| tree | edfd9119bf6484b11923cc08e582e170d219302e /test/api.js | |
| parent | [Server] Fix bug (diff) | |
| download | misskey-a6ce54ec1818e5f1dc0b1a600aa1ddd3ee48b90e.tar.gz misskey-a6ce54ec1818e5f1dc0b1a600aa1ddd3ee48b90e.tar.bz2 misskey-a6ce54ec1818e5f1dc0b1a600aa1ddd3ee48b90e.zip | |
[Test] Add some tests
Diffstat (limited to 'test/api.js')
| -rw-r--r-- | test/api.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/test/api.js b/test/api.js index 87773e7baa..42f91779d5 100644 --- a/test/api.js +++ b/test/api.js @@ -733,6 +733,45 @@ describe('API', () => { }); })); }); + + describe('drive/files/update', () => { + it('ドライブのファイルを更新できる', () => new Promise(async (done) => { + const me = await insertSakurako(); + const file = await insertDriveFile({ + user_id: me._id + }); + const newName = 'いちごパスタ.png'; + request('/drive/files/update', { + file_id: file._id.toString(), + name: newName + }, me).then(res => { + res.should.have.status(200); + res.body.should.be.a('object'); + res.body.should.have.property('name').eql(newName); + done(); + }); + })); + + it('ファイルが存在しなかったら怒る', () => new Promise(async (done) => { + request('/drive/files/update', { + file_id: '000000000000000000000000', + name: 'いちごパスタ.png' + }).then(res => { + res.should.have.status(400); + done(); + }); + })); + + it('間違ったIDで怒られる', () => new Promise(async (done) => { + request('/drive/files/update', { + file_id: 'kyoppie', + name: 'いちごパスタ.png' + }).then(res => { + res.should.have.status(400); + done(); + }); + })); + }); }); async function insertSakurako(opts) { @@ -752,3 +791,9 @@ async function insertHimawari(opts) { password: '$2a$08$OPESxR2RE/ZijjGanNKk6ezSqGFitqsbZqTjWUZPLhORMKxHCbc4O' // ilovesakurako }, opts)); } + +async function insertDriveFile(opts) { + return await db.get('drive_files').insert(Object.assign({ + name: 'strawberry-pasta.png' + }, opts)); +} |