mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
import {dirname, join} from 'node:path';
|
|
import {fileURLToPath} from 'node:url';
|
|
import {mkdirSync} from 'node:fs';
|
|
import serveOnce from 'serve-once';
|
|
import test from 'supertape';
|
|
import {rimraf} from 'rimraf';
|
|
import cloudcmd from '../../server/cloudcmd.mjs';
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = dirname(__filename);
|
|
|
|
const config = {
|
|
root: new URL('..', import.meta.url).pathname,
|
|
};
|
|
|
|
const configManager = cloudcmd.createConfigManager();
|
|
|
|
configManager('auth', false);
|
|
const {request} = serveOnce(cloudcmd, {
|
|
config,
|
|
configManager,
|
|
});
|
|
|
|
const fixtureDir = join(__dirname, '..', 'fixture') + '/';
|
|
|
|
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();
|
|
});
|