mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
refactor(move-files) move out from rest
This commit is contained in:
parent
d10c024d8d
commit
b269ce95b4
3 changed files with 74 additions and 39 deletions
|
|
@ -44,8 +44,7 @@ test('cloudcmd: rest: mv', (t) => {
|
|||
t.equal(body, 'move: ok("["mv.txt"]")', 'should move');
|
||||
t.end();
|
||||
|
||||
const file = fs.readFileSync(`${tmp}/mv.txt`);
|
||||
fs.writeFileSync(`${fixtureDir}/mv.txt`, file);
|
||||
fs.renameSync(`${tmp}/mv.txt`, `${fixtureDir}/mv.txt`);
|
||||
|
||||
after();
|
||||
})
|
||||
|
|
@ -54,3 +53,31 @@ test('cloudcmd: rest: mv', (t) => {
|
|||
});
|
||||
});
|
||||
|
||||
test('cloudcmd: rest: mv: rename', (t) => {
|
||||
before({}, (port, after) => {
|
||||
const tmp = join(fixtureDir, 'tmp');
|
||||
const files = {
|
||||
from: '/fixture/mv.txt',
|
||||
to: '/fixture/tmp/mv.txt',
|
||||
};
|
||||
|
||||
mkdirp.sync(tmp);
|
||||
|
||||
const rmTmp = () => rimraf.sync(tmp);
|
||||
|
||||
put(`http://localhost:${port}/api/v1/mv`, files)
|
||||
.then(warp(_pullout, 'string'))
|
||||
.then((body) => {
|
||||
const expected = 'move: ok("{"from":"/fixture/mv.txt","to":"/fixture/tmp/mv.txt"}")';
|
||||
|
||||
t.equal(body, expected, 'should move');
|
||||
t.end();
|
||||
|
||||
fs.renameSync(`${tmp}/mv.txt`, `${fixtureDir}/mv.txt`);
|
||||
|
||||
after();
|
||||
})
|
||||
.catch(console.error)
|
||||
.then(rmTmp);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue