mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 18:55:26 +00:00
43 lines
927 B
JavaScript
43 lines
927 B
JavaScript
'use strict';
|
|
|
|
const {mkdirSync} = require('fs');
|
|
const {join} = require('path');
|
|
const test = require('supertape');
|
|
const rimraf = require('rimraf');
|
|
|
|
const fixtureDir = join(__dirname, '..', 'fixture') + '/';
|
|
const config = {
|
|
root: join(__dirname, '..'),
|
|
};
|
|
|
|
const cloudcmd = require('../..');
|
|
const configManager = cloudcmd.createConfigManager();
|
|
configManager('auth', false);
|
|
|
|
const {request} = require('serve-once')(cloudcmd, {
|
|
config,
|
|
configManager,
|
|
});
|
|
|
|
test('cloudcmd: rest: copy', async (t) => {
|
|
const tmp = join(fixtureDir, 'tmp');
|
|
const files = {
|
|
from: '/fixture/',
|
|
to: '/fixture/tmp',
|
|
names: [
|
|
'copy.txt',
|
|
],
|
|
};
|
|
|
|
mkdirSync(tmp);
|
|
|
|
const {body} = await request.put(`/api/v1/copy`, {
|
|
body: files,
|
|
});
|
|
|
|
rimraf.sync(tmp);
|
|
|
|
t.equal(body, 'copy: ok("["copy.txt"]")', 'should return result');
|
|
t.end();
|
|
});
|
|
|