test(fs) serve-once

This commit is contained in:
coderaiser 2018-11-08 19:13:10 +02:00
parent 7fc4e2f807
commit bb9dde869e
2 changed files with 11 additions and 23 deletions

View file

@ -217,6 +217,7 @@
"supermenu": "^2.1.2",
"tape": "^4.4.0",
"tar-stream": "^1.5.2",
"try-to-tape": "^1.0.0",
"unionfs": "^3.0.2",
"url-loader": "^1.0.1",
"version-io": "^2.0.1",

View file

@ -1,29 +1,16 @@
'use strict';
const test = require('tape');
const {promisify} = require('es6-promisify');
const pullout = require('pullout');
const request = require('request');
const before = require('../before');
const tryToTape = require('try-to-tape');
const test = tryToTape(require('tape'));
const warp = (fn, ...a) => (...b) => fn(...b, ...a);
const _pullout = promisify(pullout);
const cloudcmd = require('../..');
const {request} = require('serve-once')(cloudcmd);
const get = promisify((url, fn) => {
fn(null, request(url));
});
test('cloudcmd: rest: fs: path', (t) => {
before((port, after) => {
get(`http://localhost:${port}/api/v1/fs`)
.then(warp(_pullout, 'string'))
.then(JSON.parse)
.then((dir) => {
t.equal('/', dir.path, 'should dir path be "/"');
t.end();
after();
})
.catch(console.error);
});
test('cloudcmd: rest: fs: path', async (t) => {
const {body} = await request.get(`/api/v1/fs`);
const {path} = JSON.parse(body);
t.equal('/', path, 'should dir path be "/"');
t.end();
});