mirror of
https://github.com/HeyPuter/puter.git
synced 2026-08-16 02:57:57 +00:00
* ci: init e2e test for browser env stash changes * test: update fsentry definition, add tests stash changes * test: pass puter-js mkdir test * test: add test for puter-js move * tidy code * tidy code * doc: add docs for playwright test * recover memoryfs * test: puter-js readdir/stat * test: puter-js write * test: puter-js read * test: puter-js move_cart * test: fix failed tests on move * tests: rename files * test: puter-js copy_cart * tests: puter-js batch/delete, read config from file * ci: add vitest * ci: update names and timeout * ci: simplify playwright-test * ci: simplify api-test * move "api-tester" from tools to tests * test: update example config * test: remove folder tests/api-tester/ci * test: unify config location * test: remove unused files * ci: fix wrong config * ci: fix wrong path * test: add docs * ci: update timeout, print artifact url
95 lines
3.4 KiB
JavaScript
95 lines
3.4 KiB
JavaScript
const { expect } = require("chai");
|
|
const fs = require('fs');
|
|
|
|
module.exports = {
|
|
name: 'move',
|
|
do: async t => {
|
|
// setup conditions for tests
|
|
await t.mkdir('dir_with_contents');
|
|
await t.write('dir_with_contents/a.txt', 'move test\n');
|
|
await t.write('dir_with_contents/b.txt', 'move test\n');
|
|
await t.write('dir_with_contents/c.txt', 'move test\n');
|
|
await t.mkdir('dir_with_contents/q');
|
|
await t.mkdir('dir_with_contents/w');
|
|
await t.mkdir('dir_with_contents/e');
|
|
await t.mkdir('dir_no_contents');
|
|
await t.write('just_a_file.txt', 'move test\n');
|
|
|
|
await t.case('move file', async () => {
|
|
await t.move('just_a_file.txt', 'just_a_file_moved.txt');
|
|
const moved = await t.stat('just_a_file_moved.txt');
|
|
let threw = false;
|
|
try {
|
|
await t.stat('just_a_file.txt');
|
|
} catch (e) {
|
|
expect(e.response.status).equal(404);
|
|
threw = true;
|
|
}
|
|
expect(threw).true;
|
|
expect(moved.name).equal('just_a_file_moved.txt');
|
|
});
|
|
|
|
await t.case('move file to existing file', async () => {
|
|
await t.write('just_a_file.txt', 'move test\n');
|
|
let threw = false;
|
|
try {
|
|
await t.move('just_a_file.txt', 'dir_with_contents/a.txt');
|
|
} catch (e) {
|
|
expect(e.response.status).equal(409);
|
|
threw = true;
|
|
}
|
|
expect(threw).true;
|
|
});
|
|
|
|
/*
|
|
await t.case('move file to existing directory', async () => {
|
|
await t.move('just_a_file.txt', 'dir_with_contents');
|
|
const moved = await t.stat('dir_with_contents/just_a_file.txt');
|
|
let threw = false;
|
|
try {
|
|
await t.stat('just_a_file.txt');
|
|
} catch (e) {
|
|
expect(e.response.status).equal(404);
|
|
threw = true;
|
|
}
|
|
expect(threw).true;
|
|
expect(moved.name).equal('just_a_file.txt');
|
|
});
|
|
*/
|
|
|
|
await t.case('move directory', async () => {
|
|
await t.move('dir_no_contents', 'dir_no_contents_moved');
|
|
const moved = await t.stat('dir_no_contents_moved');
|
|
let threw = false;
|
|
try {
|
|
await t.stat('dir_no_contents');
|
|
} catch (e) {
|
|
expect(e.response.status).equal(404);
|
|
threw = true;
|
|
}
|
|
expect(threw).true;
|
|
expect(moved.name).equal('dir_no_contents_moved');
|
|
});
|
|
|
|
await t.case('move file and create parents', async () => {
|
|
await t.write('just_a_file.txt', 'move test\n', { overwrite: true });
|
|
const res = await t.move(
|
|
'just_a_file.txt',
|
|
'dir_with_contents/q/w/e/just_a_file.txt',
|
|
{ create_missing_parents: true }
|
|
);
|
|
expect(res.parent_dirs_created).length(2);
|
|
const moved = await t.stat('dir_with_contents/q/w/e/just_a_file.txt');
|
|
let threw = false;
|
|
try {
|
|
await t.stat('just_a_file.txt');
|
|
} catch (e) {
|
|
expect(e.response.status).equal(404);
|
|
threw = true;
|
|
}
|
|
expect(threw).true;
|
|
expect(moved.name).equal('just_a_file.txt');
|
|
});
|
|
}
|
|
};
|