Skip to content

Commit

Permalink
Added POST storage test
Browse files Browse the repository at this point in the history
  • Loading branch information
andris9 committed Sep 7, 2023
1 parent 5eeab92 commit a9b1b97
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
5 changes: 5 additions & 0 deletions test/api/addresses-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ describe('API Users', function () {
expect(response.body.success).to.be.true;

user = false;

const response2 = await server.delete(`/users/${user2}`).expect(200);
expect(response2.body.success).to.be.true;

user2 = false;
});

it('should POST /users/{user}/addresses', async () => {
Expand Down
62 changes: 62 additions & 0 deletions test/api/storage-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*eslint no-unused-expressions: 0, prefer-arrow-callback: 0, no-console:0 */

/* globals before: false, after: false */

'use strict';

const supertest = require('supertest');
const chai = require('chai');

const expect = chai.expect;
chai.config.includeStack = true;
const config = require('wild-config');

const server = supertest.agent(`http://127.0.0.1:${config.api.port}`);

describe('Storage tests', function () {
this.timeout(10000); // eslint-disable-line no-invalid-this

let user;

before(async () => {
// ensure that we have an existing user account
const response = await server
.post('/users')
.send({
username: 'storageuser',
password: 'secretvalue',
address: '[email protected]',
name: 'storage user'
})
.expect(200);
expect(response.body.success).to.be.true;
expect(response.body.id).to.exist;

user = response.body.id;
});

after(async () => {
if (!user) {
return;
}

const response = await server.delete(`/users/${user}`).expect(200);
expect(response.body.success).to.be.true;

user = false;
});

it('should POST /users/{user}/storage', async () => {
const response = await server
.post(`/users/${user}/storage`)
.send({
filename: 'image.gif',
contentType: 'image/gif',
encoding: 'base64',
content:
'R0lGODlhEAAQAMQAAORHHOVSKudfOulrSOp3WOyDZu6QdvCchPGolfO0o/XBs/fNwfjZ0frl3/zy7////wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAkAABAALAAAAAAQABAAAAVVICSOZGlCQAosJ6mu7fiyZeKqNKToQGDsM8hBADgUXoGAiqhSvp5QAnQKGIgUhwFUYLCVDFCrKUE1lBavAViFIDlTImbKC5Gm2hB0SlBCBMQiB0UjIQA7'
})
.expect(200);
expect(response.body.success).to.be.true;
});
});

0 comments on commit a9b1b97

Please sign in to comment.