core-3nweb-client-lib 0.44.11 → 0.45.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/core/asmail/msg/opener.js +1 -1
- package/build/core/asmail/msg/packer.js +1 -1
- package/build/core/index.d.ts +2 -2
- package/build/core/keyring/correspondent-keys.js +1 -1
- package/build/core/keyring/index.js +1 -1
- package/build/core/startup/sign-in.d.ts +1 -1
- package/build/core/startup/sign-up.d.ts +1 -1
- package/build/core/storage/index.d.ts +1 -1
- package/build/lib-client/key-derivation.d.ts +1 -1
- package/build/lib-client/xsp-fs/attrs.d.ts +3 -2
- package/build/lib-client/xsp-fs/attrs.js +7 -6
- package/build/lib-client/xsp-fs/folder-node.js +1 -1
- package/build/lib-client/xsp-fs/node-in-fs.js +1 -0
- package/build/lib-client/xsp-fs/node-persistence.js +1 -1
- package/build/lib-client/xsp-fs/xsp-payload-v2.js +1 -1
- package/build/tests/caps-api/asmail/specs/events.d.ts +2 -0
- package/build/tests/caps-api/asmail/specs/events.js +63 -0
- package/build/tests/caps-api/asmail/specs/send-to-wrong-address.d.ts +2 -0
- package/build/tests/caps-api/asmail/specs/send-to-wrong-address.js +68 -0
- package/build/tests/caps-api/asmail/specs/send-with-attacment-from-storage.d.ts +2 -0
- package/build/tests/caps-api/asmail/specs/send-with-attacment-from-storage.js +259 -0
- package/build/tests/caps-api/asmail/specs/send-without-attachments.d.ts +2 -0
- package/build/tests/caps-api/asmail/specs/send-without-attachments.js +90 -0
- package/build/tests/caps-api/asmail/test-utils.d.ts +12 -0
- package/build/tests/caps-api/asmail/test-utils.js +60 -0
- package/build/tests/caps-api/asmail.js +86 -0
- package/build/tests/caps-api/file-sink-checks/different-cases.d.ts +2 -0
- package/build/tests/caps-api/file-sink-checks/different-cases.js +47 -0
- package/build/tests/caps-api/file-sink-checks/splice.d.ts +2 -0
- package/build/tests/caps-api/file-sink-checks/splice.js +122 -0
- package/build/tests/caps-api/file-sink-checks/truncate.d.ts +2 -0
- package/build/tests/caps-api/file-sink-checks/truncate.js +122 -0
- package/build/tests/caps-api/fs-checks/local-to-synced-linking/link.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/local-to-synced-linking/link.js +82 -0
- package/build/tests/caps-api/fs-checks/local-to-synced-linking/reversed-linking.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/local-to-synced-linking/reversed-linking.js +50 -0
- package/build/tests/caps-api/fs-checks/not-versioned/deleteFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/deleteFile.js +73 -0
- package/build/tests/caps-api/fs-checks/not-versioned/deleteFolder.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/deleteFolder.js +75 -0
- package/build/tests/caps-api/fs-checks/not-versioned/getByteSink.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/getByteSink.js +96 -0
- package/build/tests/caps-api/fs-checks/not-versioned/getByteSource.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/getByteSource.js +67 -0
- package/build/tests/caps-api/fs-checks/not-versioned/getXAttr.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/getXAttr.js +77 -0
- package/build/tests/caps-api/fs-checks/not-versioned/link.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/link.js +115 -0
- package/build/tests/caps-api/fs-checks/not-versioned/listFolder.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/listFolder.js +129 -0
- package/build/tests/caps-api/fs-checks/not-versioned/listXAttrs.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/listXAttrs.js +73 -0
- package/build/tests/caps-api/fs-checks/not-versioned/makeFolder.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/makeFolder.js +95 -0
- package/build/tests/caps-api/fs-checks/not-versioned/move.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/move.js +127 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readBytes.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readBytes.js +80 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readJSONFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readJSONFile.js +59 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readLink.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readLink.js +39 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readTxtFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readTxtFile.js +54 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readonlyFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readonlyFile.js +55 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readonlySubRoot.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/readonlySubRoot.js +55 -0
- package/build/tests/caps-api/fs-checks/not-versioned/select.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/select.js +119 -0
- package/build/tests/caps-api/fs-checks/not-versioned/stat.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/stat.js +96 -0
- package/build/tests/caps-api/fs-checks/not-versioned/updateXAttrs.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/updateXAttrs.js +126 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writableFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writableFile.js +79 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writableSubRoot.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writableSubRoot.js +90 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writeBytes.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writeBytes.js +137 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writeJSONFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writeJSONFile.js +101 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writeTxtFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/not-versioned/writeTxtFile.js +100 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/startUpload.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/startUpload.js +187 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/stat.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/stat.js +70 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/status.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/status.js +53 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/upload.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/sync-on-one-dev/upload.js +194 -0
- package/build/tests/caps-api/fs-checks/sync-with-two-devs/conflicts.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/sync-with-two-devs/conflicts.js +396 -0
- package/build/tests/caps-api/fs-checks/sync-with-two-devs/update-propagation.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/sync-with-two-devs/update-propagation.js +229 -0
- package/build/tests/caps-api/fs-checks/test-utils.d.ts +34 -0
- package/build/tests/caps-api/fs-checks/test-utils.js +95 -0
- package/build/tests/caps-api/fs-checks/versioned/archiveCurrent.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/archiveCurrent.js +73 -0
- package/build/tests/caps-api/fs-checks/versioned/getByteSink.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/getByteSink.js +122 -0
- package/build/tests/caps-api/fs-checks/versioned/getByteSource.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/getByteSource.js +71 -0
- package/build/tests/caps-api/fs-checks/versioned/listFolder.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/listFolder.js +109 -0
- package/build/tests/caps-api/fs-checks/versioned/listVersions.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/listVersions.js +48 -0
- package/build/tests/caps-api/fs-checks/versioned/readBytes.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/readBytes.js +90 -0
- package/build/tests/caps-api/fs-checks/versioned/readJSONFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/readJSONFile.js +60 -0
- package/build/tests/caps-api/fs-checks/versioned/readTxtFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/readTxtFile.js +56 -0
- package/build/tests/caps-api/fs-checks/versioned/stat.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/stat.js +80 -0
- package/build/tests/caps-api/fs-checks/versioned/watchFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/watchFile.js +64 -0
- package/build/tests/caps-api/fs-checks/versioned/writeBytes.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/writeBytes.js +128 -0
- package/build/tests/caps-api/fs-checks/versioned/writeJSONFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/writeJSONFile.js +111 -0
- package/build/tests/caps-api/fs-checks/versioned/writeTxtFile.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/versioned/writeTxtFile.js +107 -0
- package/build/tests/caps-api/fs-checks/with-core-restarts/xattrs.d.ts +2 -0
- package/build/tests/caps-api/fs-checks/with-core-restarts/xattrs.js +50 -0
- package/build/tests/caps-api/keyrings.js +69 -0
- package/build/tests/caps-api/mailerid.d.ts +1 -0
- package/build/tests/caps-api/mailerid.js +59 -0
- package/build/tests/caps-api/startup/signin-empty-cache.d.ts +1 -0
- package/build/tests/caps-api/startup/signin-empty-cache.js +108 -0
- package/build/tests/caps-api/startup/signin-with-cache.d.ts +1 -0
- package/build/tests/caps-api/startup/signin-with-cache.js +83 -0
- package/build/tests/caps-api/startup/signup-with-token.d.ts +1 -0
- package/build/tests/caps-api/startup/signup-with-token.js +53 -0
- package/build/tests/caps-api/startup/signup.d.ts +1 -0
- package/build/tests/caps-api/startup/signup.js +86 -0
- package/build/tests/caps-api/storage.d.ts +1 -0
- package/build/tests/caps-api/storage.js +225 -0
- package/build/tests/computer.3nweb.core/id-manager.d.ts +1 -0
- package/build/tests/computer.3nweb.core/id-manager.js +78 -0
- package/build/tests/computer.3nweb.core/inbox/msg-indexing.d.ts +1 -0
- package/build/tests/computer.3nweb.core/inbox/msg-indexing.js +145 -0
- package/build/tests/computer.3nweb.core/keyrings.d.ts +1 -0
- package/build/tests/computer.3nweb.core/keyrings.js +64 -0
- package/build/tests/computer.3nweb.core/test-utils.d.ts +21 -0
- package/build/tests/computer.3nweb.core/test-utils.js +92 -0
- package/build/tests/jasmine.d.ts +1 -0
- package/build/tests/jasmine.js +45 -0
- package/build/tests/libs-for-tests/bytes-equal.d.ts +1 -0
- package/build/tests/libs-for-tests/bytes-equal.js +32 -0
- package/build/tests/libs-for-tests/caps-ipc-wrap.d.ts +11 -0
- package/build/tests/libs-for-tests/caps-ipc-wrap.js +55 -0
- package/build/tests/libs-for-tests/core-runner.d.ts +39 -0
- package/build/tests/libs-for-tests/core-runner.js +231 -0
- package/build/tests/libs-for-tests/jasmine-utils.d.ts +13 -0
- package/build/tests/libs-for-tests/jasmine-utils.js +110 -0
- package/build/tests/libs-for-tests/json-equal.d.ts +1 -0
- package/build/tests/libs-for-tests/json-equal.js +78 -0
- package/build/tests/libs-for-tests/services-runner.d.ts +18 -0
- package/build/tests/libs-for-tests/services-runner.js +64 -0
- package/build/tests/libs-for-tests/setups.d.ts +51 -0
- package/build/tests/libs-for-tests/setups.js +305 -0
- package/build/tests/libs-for-tests/spec-module.d.ts +16 -0
- package/build/tests/libs-for-tests/spec-module.js +92 -0
- package/build/tests/libs-for-tests/startup.d.ts +1 -0
- package/build/tests/libs-for-tests/startup.js +29 -0
- package/build/tests/libs-for-tests/watching.d.ts +7 -0
- package/build/tests/libs-for-tests/watching.js +33 -0
- package/build/tests/units/canonical-address.d.ts +1 -0
- package/build/tests/units/canonical-address.js +41 -0
- package/build/tests/units/device-fs.d.ts +1 -0
- package/build/tests/units/device-fs.js +70 -0
- package/build/tests/units/folder-node-serialization.d.ts +1 -0
- package/build/tests/units/folder-node-serialization.js +74 -0
- package/build/tests/units/mid-sigs-NaCl-Ed.d.ts +1 -0
- package/build/tests/units/mid-sigs-NaCl-Ed.js +123 -0
- package/build/tests/units/number-line.d.ts +1 -0
- package/build/tests/units/number-line.js +63 -0
- package/build/tests/units/obj-folders.d.ts +1 -0
- package/build/tests/units/obj-folders.js +152 -0
- package/package.json +11 -3
- package/postinstall.js +1 -1
- package/build/cryptors.d.ts +0 -1
- package/build/cryptors.js +0 -34
- package/build/lib-client/cryptor/cryptor-in-worker.d.ts +0 -20
- package/build/lib-client/cryptor/cryptor-in-worker.js +0 -357
- package/build/lib-client/cryptor/cryptor-wasm.js +0 -1
- package/build/lib-client/cryptor/cryptor.d.ts +0 -30
- package/build/lib-client/cryptor/cryptor.js +0 -44
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-client/cryptor/in-proc-js.d.ts +0 -2
- package/build/lib-client/cryptor/in-proc-js.js +0 -57
- package/build/lib-client/cryptor/in-proc-wasm.d.ts +0 -2
- package/build/lib-client/cryptor/in-proc-wasm.js +0 -176
- package/build/lib-client/cryptor/serialization-for-wasm.d.ts +0 -35
- package/build/lib-client/cryptor/serialization-for-wasm.js +0 -57
- package/build/lib-client/cryptor/wasm-mp1-modules.d.ts +0 -5
- package/build/lib-client/cryptor/wasm-mp1-modules.js +0 -78
- package/build/lib-client/cryptor/worker-js.js +0 -131
- package/build/lib-client/cryptor/worker-wasm.js +0 -37
- package/build/protos/cryptor.proto.js +0 -1804
- /package/build/lib-client/{cryptor/cryptor-work-labels.d.ts → cryptor-work-labels.d.ts} +0 -0
- /package/build/lib-client/{cryptor/cryptor-work-labels.js → cryptor-work-labels.js} +0 -0
- /package/build/{lib-client/cryptor/worker-js.d.ts → tests/caps-api/asmail.d.ts} +0 -0
- /package/build/{lib-client/cryptor/worker-wasm.d.ts → tests/caps-api/keyrings.d.ts} +0 -0
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright 2019 - 2020, 2022, 2025 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.clearFS = clearFS;
|
|
20
|
+
exports.makeSetupWithTwoDevsFSs = makeSetupWithTwoDevsFSs;
|
|
21
|
+
exports.observeFolderForOneEvent = observeFolderForOneEvent;
|
|
22
|
+
exports.observeFileForOneEvent = observeFileForOneEvent;
|
|
23
|
+
const rxjs_1 = require("rxjs");
|
|
24
|
+
const operators_1 = require("rxjs/operators");
|
|
25
|
+
async function clearFS(fs) {
|
|
26
|
+
let items = await fs.listFolder('');
|
|
27
|
+
let delTasks = [];
|
|
28
|
+
for (let f of items) {
|
|
29
|
+
if (f.isFile) {
|
|
30
|
+
delTasks.push(fs.deleteFile(f.name));
|
|
31
|
+
}
|
|
32
|
+
else if (f.isFolder) {
|
|
33
|
+
delTasks.push(fs.deleteFolder(f.name, true));
|
|
34
|
+
}
|
|
35
|
+
else if (f.isLink) {
|
|
36
|
+
delTasks.push(fs.deleteLink(f.name));
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
throw new Error(`File system item is neither file, nor folder, nor link`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
await Promise.all(delTasks);
|
|
43
|
+
}
|
|
44
|
+
function makeSetupWithTwoDevsFSs(testFolder) {
|
|
45
|
+
const fsSetup = {};
|
|
46
|
+
const setupDevsAndFSs = async (baseSetup) => {
|
|
47
|
+
if (!baseSetup.isUp) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const w3n1 = baseSetup.testAppCapsByUserIndex(0);
|
|
51
|
+
const dev2 = await baseSetup.sndDevByUserIndex(0);
|
|
52
|
+
const dev1AppFS = await w3n1.storage.getAppSyncedFS();
|
|
53
|
+
const dev2AppFS = () => dev2.w3n.storage.getAppSyncedFS();
|
|
54
|
+
let dev1FS;
|
|
55
|
+
let dev2FS;
|
|
56
|
+
fsSetup.dev1FS = () => dev1FS;
|
|
57
|
+
fsSetup.dev2FS = () => dev2FS;
|
|
58
|
+
fsSetup.dev2 = {
|
|
59
|
+
start: async () => {
|
|
60
|
+
await dev2.start();
|
|
61
|
+
dev2FS = await (await dev2AppFS()).writableSubRoot(testFolder);
|
|
62
|
+
},
|
|
63
|
+
stop: async () => {
|
|
64
|
+
dev2FS = undefined;
|
|
65
|
+
await dev2.stop();
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
fsSetup.resetFS = async () => {
|
|
69
|
+
await clearFS(dev1AppFS);
|
|
70
|
+
dev1FS = await dev1AppFS.writableSubRoot(testFolder, { create: true, exclusive: true });
|
|
71
|
+
await dev1AppFS.v.sync.upload(testFolder);
|
|
72
|
+
await dev1AppFS.v.sync.upload('');
|
|
73
|
+
const d2AppFS = await dev2AppFS();
|
|
74
|
+
const status = await d2AppFS.v.sync.status('');
|
|
75
|
+
if (status.state === 'behind') {
|
|
76
|
+
await d2AppFS.v.sync.adoptRemote('');
|
|
77
|
+
}
|
|
78
|
+
else if (status.state === 'conflicting') {
|
|
79
|
+
throw new Error(`Test file system on a second device has inconvenient conflicting sync state`);
|
|
80
|
+
}
|
|
81
|
+
dev2FS = await d2AppFS.writableSubRoot(testFolder, { create: false });
|
|
82
|
+
};
|
|
83
|
+
await fsSetup.resetFS();
|
|
84
|
+
fsSetup.isUp = true;
|
|
85
|
+
};
|
|
86
|
+
return { fsSetup, setupDevsAndFSs };
|
|
87
|
+
}
|
|
88
|
+
function observeFolderForOneEvent(fs, path = '') {
|
|
89
|
+
return (0, rxjs_1.lastValueFrom)((new rxjs_1.Observable(obs => fs.watchTree(path, 1, obs)))
|
|
90
|
+
.pipe((0, operators_1.take)(1)));
|
|
91
|
+
}
|
|
92
|
+
function observeFileForOneEvent(fs, path) {
|
|
93
|
+
return (0, rxjs_1.lastValueFrom)((new rxjs_1.Observable(obs => fs.watchFile(path, obs)))
|
|
94
|
+
.pipe((0, operators_1.take)(1)));
|
|
95
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2022 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.specs = void 0;
|
|
20
|
+
const random_node_1 = require("../../../../lib-common/random-node");
|
|
21
|
+
exports.specs = {
|
|
22
|
+
description: '.v.archiveCurrent',
|
|
23
|
+
its: []
|
|
24
|
+
};
|
|
25
|
+
let it = { expectation: 'fails on non-existing path' };
|
|
26
|
+
it.func = async function (s) {
|
|
27
|
+
const { testFS } = s;
|
|
28
|
+
const fName = 'non-existing-path';
|
|
29
|
+
await testFS.v.archiveCurrent(fName).then(() => fail('should fail for non-existing folder'), exc => {
|
|
30
|
+
expect(exc.notFound).toBe(true);
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.specs.its.push(it);
|
|
34
|
+
it = { expectation: 'archives current synced version' };
|
|
35
|
+
it.func = async function (s) {
|
|
36
|
+
const { testFS } = s;
|
|
37
|
+
const filePath = `with archived inside/file`;
|
|
38
|
+
const initFileTxt = await (0, random_node_1.stringOfB64Chars)(30);
|
|
39
|
+
await testFS.v.writeTxtFile(filePath, initFileTxt);
|
|
40
|
+
let versions = await testFS.v.listVersions(filePath);
|
|
41
|
+
expect(versions.archived).toBeUndefined();
|
|
42
|
+
if (testFS.v.sync) {
|
|
43
|
+
let syncStatus = await testFS.v.sync.status(filePath);
|
|
44
|
+
expect(syncStatus.state).toBe('unsynced');
|
|
45
|
+
await testFS.v.archiveCurrent(filePath).then(() => fail(`synced fs can archive only synced version`), (exc) => {
|
|
46
|
+
expect(exc.type).toBe('fs-sync');
|
|
47
|
+
expect(exc.notSynced).toBeTrue();
|
|
48
|
+
});
|
|
49
|
+
await testFS.v.sync.upload(filePath);
|
|
50
|
+
syncStatus = await testFS.v.sync.status(filePath);
|
|
51
|
+
expect(syncStatus.state).toBe('synced');
|
|
52
|
+
expect(syncStatus.synced.archived).toBeUndefined();
|
|
53
|
+
await testFS.v.archiveCurrent(filePath);
|
|
54
|
+
syncStatus = await testFS.v.sync.status(filePath);
|
|
55
|
+
expect(syncStatus.synced.archived).toContain(syncStatus.synced.latest);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
await testFS.v.archiveCurrent(filePath);
|
|
59
|
+
}
|
|
60
|
+
const fileVer = (await testFS.stat(filePath)).version;
|
|
61
|
+
versions = await testFS.v.listVersions(filePath);
|
|
62
|
+
expect(versions.archived).toContain(fileVer);
|
|
63
|
+
// after writing new version, archived version can be read
|
|
64
|
+
expect(await testFS.v.writeBytes(filePath, await (0, random_node_1.bytes)(60)))
|
|
65
|
+
.toBeGreaterThan(fileVer);
|
|
66
|
+
expect((await testFS.v.readTxtFile(filePath, { archivedVersion: fileVer })).txt).toBe(initFileTxt);
|
|
67
|
+
if (testFS.v.sync) {
|
|
68
|
+
await testFS.v.sync.upload(filePath);
|
|
69
|
+
expect((await testFS.v.readTxtFile(filePath, { archivedVersion: fileVer })).txt).toBe(initFileTxt);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
exports.specs.its.push(it);
|
|
73
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016 - 2018, 2020 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.specs = void 0;
|
|
20
|
+
const random_node_1 = require("../../../../lib-common/random-node");
|
|
21
|
+
const bytes_equal_1 = require("../../../libs-for-tests/bytes-equal");
|
|
22
|
+
const sink_utils_1 = require("../../../../lib-common/obj-streaming/sink-utils");
|
|
23
|
+
exports.specs = {
|
|
24
|
+
description: '.v.getByteSink',
|
|
25
|
+
its: []
|
|
26
|
+
};
|
|
27
|
+
let it = {
|
|
28
|
+
expectation: 'if not allowed to create, fails for missing file'
|
|
29
|
+
};
|
|
30
|
+
it.func = async function (s) {
|
|
31
|
+
const { testFS } = s;
|
|
32
|
+
try {
|
|
33
|
+
await testFS.v.getByteSink('non-existing-file', {});
|
|
34
|
+
fail('should fail for missing file');
|
|
35
|
+
}
|
|
36
|
+
catch (e) {
|
|
37
|
+
expect(e.notFound).toBe(true);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
exports.specs.its.push(it);
|
|
41
|
+
it = { expectation: 'creates file in existing folder' };
|
|
42
|
+
it.func = async function (s) {
|
|
43
|
+
const { testFS } = s;
|
|
44
|
+
const path = 'file1';
|
|
45
|
+
const content = (0, random_node_1.bytesSync)(2 * 1024);
|
|
46
|
+
expect(await testFS.checkFilePresence(path)).toBe(false);
|
|
47
|
+
const { sink, version: v } = await testFS.v.getByteSink(path, { create: true });
|
|
48
|
+
expect(await testFS.checkFilePresence(path)).toBe(true);
|
|
49
|
+
expect(await sink.getSize()).toBe(0);
|
|
50
|
+
const continousSink = (0, sink_utils_1.makeContinuousSink)(sink);
|
|
51
|
+
for (let pointer = 0; pointer < content.length; pointer += 250) {
|
|
52
|
+
const chunkEnd = pointer + 250;
|
|
53
|
+
await continousSink(content.subarray(pointer, chunkEnd));
|
|
54
|
+
expect(await sink.getSize()).toBe(Math.min(chunkEnd, content.length));
|
|
55
|
+
}
|
|
56
|
+
expect(await sink.getSize()).toBe(content.length);
|
|
57
|
+
await continousSink(null);
|
|
58
|
+
const { bytes, version } = await testFS.v.readBytes(path);
|
|
59
|
+
expect(!!bytes).toBe(true);
|
|
60
|
+
expect((0, bytes_equal_1.bytesEqual)(content, bytes)).toBe(true);
|
|
61
|
+
expect(version).toBe(v);
|
|
62
|
+
};
|
|
63
|
+
exports.specs.its.push(it);
|
|
64
|
+
it = { expectation: 'creates parent folder(s) on the way' };
|
|
65
|
+
it.func = async function (s) {
|
|
66
|
+
const { testFS } = s;
|
|
67
|
+
const fName = 'file2';
|
|
68
|
+
const grParent = 'grand-parent';
|
|
69
|
+
const parent2 = 'grand-parent/parent2';
|
|
70
|
+
const path = `${parent2}/${fName}`;
|
|
71
|
+
expect(await testFS.checkFolderPresence(grParent)).toBe(false);
|
|
72
|
+
expect(await testFS.checkFolderPresence(parent2)).toBe(false);
|
|
73
|
+
expect(await testFS.checkFolderPresence(path)).toBe(false);
|
|
74
|
+
const { sink } = await testFS.v.getByteSink(path, { create: true });
|
|
75
|
+
expect(await testFS.checkFolderPresence(grParent)).toBe(true);
|
|
76
|
+
expect(await testFS.checkFolderPresence(parent2)).toBe(true);
|
|
77
|
+
expect(await testFS.checkFilePresence(path)).toBe(true);
|
|
78
|
+
// note that file existed before sink closing
|
|
79
|
+
await sink.done();
|
|
80
|
+
};
|
|
81
|
+
exports.specs.its.push(it);
|
|
82
|
+
it = { expectation: 'opens existing file' };
|
|
83
|
+
it.func = async function (s) {
|
|
84
|
+
const { testFS } = s;
|
|
85
|
+
const path = 'file2';
|
|
86
|
+
const bytes = (0, random_node_1.bytesSync)(2 * 1024);
|
|
87
|
+
const originalSize = bytes.length;
|
|
88
|
+
const v = await testFS.v.writeBytes(path, bytes);
|
|
89
|
+
expect(await testFS.checkFilePresence(path)).toBe(true);
|
|
90
|
+
const { sink, version } = await testFS.v.getByteSink(path, { truncate: false });
|
|
91
|
+
expect(version).withContext('it should be next file version').toBeGreaterThan(v);
|
|
92
|
+
expect(await sink.getSize()).withContext('Existing file should be opened as is').toBe(originalSize);
|
|
93
|
+
const continousSink = (0, sink_utils_1.makeContinuousSink)(sink, originalSize);
|
|
94
|
+
await continousSink(bytes);
|
|
95
|
+
expect(await sink.getSize()).toBe(originalSize + bytes.length);
|
|
96
|
+
await continousSink(null);
|
|
97
|
+
};
|
|
98
|
+
exports.specs.its.push(it);
|
|
99
|
+
it = { expectation: `doesn't advance file version when write is cancelled` };
|
|
100
|
+
it.func = async function (s) {
|
|
101
|
+
const { testFS } = s;
|
|
102
|
+
const path = 'file2';
|
|
103
|
+
const bytes = (0, random_node_1.bytesSync)(2 * 1024);
|
|
104
|
+
const initVersion = await testFS.v.writeBytes(path, bytes);
|
|
105
|
+
let { sink, version } = await testFS.v.getByteSink(path, {});
|
|
106
|
+
expect(version).toBe(initVersion + 1);
|
|
107
|
+
await sink.splice(0, 20, bytes.subarray(100, 120));
|
|
108
|
+
await sink.done(new Error(`Cancelling write to sink process`));
|
|
109
|
+
({ version } = await testFS.v.readBytes(path));
|
|
110
|
+
expect(version).toBe(initVersion);
|
|
111
|
+
({ sink, version } = await testFS.v.getByteSink(path, {}));
|
|
112
|
+
expect(version).toBe(initVersion + 1);
|
|
113
|
+
await sink.splice(1000, 20, bytes.subarray(0, 20));
|
|
114
|
+
await sink.done();
|
|
115
|
+
const { version: finV, bytes: finB } = await testFS.v.readBytes(path);
|
|
116
|
+
expect(finV).toBe(version);
|
|
117
|
+
expect((0, bytes_equal_1.bytesEqual)(finB.subarray(0, 1000), bytes.subarray(0, 1000))).toBe(true);
|
|
118
|
+
expect((0, bytes_equal_1.bytesEqual)(finB.subarray(1000, 1020), bytes.subarray(0, 20))).toBe(true);
|
|
119
|
+
expect((0, bytes_equal_1.bytesEqual)(finB.subarray(1020), bytes.subarray(1020))).toBe(true);
|
|
120
|
+
};
|
|
121
|
+
exports.specs.its.push(it);
|
|
122
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016 - 2018, 2020 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.specs = void 0;
|
|
20
|
+
const random_node_1 = require("../../../../lib-common/random-node");
|
|
21
|
+
const bytes_equal_1 = require("../../../libs-for-tests/bytes-equal");
|
|
22
|
+
exports.specs = {
|
|
23
|
+
description: '.v.getByteSource',
|
|
24
|
+
its: []
|
|
25
|
+
};
|
|
26
|
+
let it = { expectation: 'fails to read non-existent file' };
|
|
27
|
+
it.func = async function (s) {
|
|
28
|
+
const { testFS } = s;
|
|
29
|
+
try {
|
|
30
|
+
await testFS.v.getByteSource('non-existing-file');
|
|
31
|
+
fail('should fail for missing file');
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
expect(e.notFound).toBe(true);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
exports.specs.its.push(it);
|
|
38
|
+
it = { expectation: 'reads file bytes with seeking available' };
|
|
39
|
+
it.func = async function (s) {
|
|
40
|
+
const { testFS } = s;
|
|
41
|
+
let original = (0, random_node_1.bytesSync)(12 * 1024 + 3);
|
|
42
|
+
let fName = 'file1';
|
|
43
|
+
let v1 = await testFS.v.writeBytes(fName, original);
|
|
44
|
+
let { src, version } = await testFS.v.getByteSource(fName);
|
|
45
|
+
expect(version).toBe(v1);
|
|
46
|
+
expect(await src.getPosition()).toBe(0);
|
|
47
|
+
let chunk = await src.readNext(200);
|
|
48
|
+
expect((0, bytes_equal_1.bytesEqual)(chunk, original.subarray(0, 200))).toBe(true);
|
|
49
|
+
await src.seek(3000);
|
|
50
|
+
expect(await src.getPosition()).withContext('seek method changes position in file.').toBe(3000);
|
|
51
|
+
chunk = await src.readNext(200);
|
|
52
|
+
expect((0, bytes_equal_1.bytesEqual)(chunk, original.subarray(3000, 3200))).toBe(true);
|
|
53
|
+
await src.seek(11000);
|
|
54
|
+
expect(await src.getPosition()).withContext('seek method changes position in file.').toBe(11000);
|
|
55
|
+
chunk = await src.readNext(200);
|
|
56
|
+
expect((0, bytes_equal_1.bytesEqual)(chunk, original.subarray(11000, 11200))).toBe(true);
|
|
57
|
+
await src.seek(1000);
|
|
58
|
+
expect(await src.getPosition()).toBe(1000);
|
|
59
|
+
chunk = await src.readNext(200);
|
|
60
|
+
expect((0, bytes_equal_1.bytesEqual)(chunk, original.subarray(1000, 1200))).toBe(true);
|
|
61
|
+
chunk = await src.readNext(undefined);
|
|
62
|
+
expect((0, bytes_equal_1.bytesEqual)(chunk, original.subarray(1200))).withContext('read should be from current position to file\'s end').toBe(true);
|
|
63
|
+
expect(await src.readNext(100)).withContext('undefined is returned, when there are no more bytes to read').toBeUndefined();
|
|
64
|
+
let v2 = await testFS.v.writeBytes(fName, new Uint8Array(0));
|
|
65
|
+
expect(v2).toBeGreaterThan(v1);
|
|
66
|
+
({ src, version } = await testFS.v.getByteSource(fName));
|
|
67
|
+
expect(await src.readNext(100)).withContext('reading empty file should produce undefined').toBeUndefined();
|
|
68
|
+
expect(version).toBe(v2);
|
|
69
|
+
};
|
|
70
|
+
exports.specs.its.push(it);
|
|
71
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016, 2018, 2020 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.specs = void 0;
|
|
20
|
+
const json_equal_1 = require("../../../libs-for-tests/json-equal");
|
|
21
|
+
exports.specs = {
|
|
22
|
+
description: '.v.listFolder',
|
|
23
|
+
its: []
|
|
24
|
+
};
|
|
25
|
+
let it = { expectation: 'lists root' };
|
|
26
|
+
it.func = async function (s) {
|
|
27
|
+
const { testFS } = s;
|
|
28
|
+
let { lst, version } = await testFS.v.listFolder('');
|
|
29
|
+
expect(Array.isArray(lst)).toBe(true);
|
|
30
|
+
expect(typeof version).toBe('number');
|
|
31
|
+
expect(lst.length).toBe(0);
|
|
32
|
+
const initVersion = version;
|
|
33
|
+
await testFS.makeFolder('folder1');
|
|
34
|
+
await testFS.writeTxtFile('file1', '');
|
|
35
|
+
await testFS.writeTxtFile('folder1/file2', '');
|
|
36
|
+
({ lst, version } = await testFS.v.listFolder(''));
|
|
37
|
+
expect(lst.length).toBe(2);
|
|
38
|
+
expect(version).toBe(initVersion + 2);
|
|
39
|
+
for (let entry of lst) {
|
|
40
|
+
if (entry.isFile) {
|
|
41
|
+
expect(entry.name).toBe('file1');
|
|
42
|
+
}
|
|
43
|
+
else if (entry.isFolder) {
|
|
44
|
+
expect(entry.name).toBe('folder1');
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
fail(`folder listing has unknown type: ${JSON.stringify(entry, null, ' ')}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
let lst2 = (await testFS.v.listFolder('.')).lst;
|
|
51
|
+
expect((0, json_equal_1.deepEqual)(lst2, lst)).toBe(true);
|
|
52
|
+
lst2 = (await testFS.v.listFolder('/')).lst;
|
|
53
|
+
expect((0, json_equal_1.deepEqual)(lst2, lst)).toBe(true);
|
|
54
|
+
lst2 = (await testFS.v.listFolder('../../')).lst;
|
|
55
|
+
expect((0, json_equal_1.deepEqual)(lst2, lst)).toBe(true);
|
|
56
|
+
};
|
|
57
|
+
exports.specs.its.push(it);
|
|
58
|
+
it = { expectation: 'fails to list non-existing folder' };
|
|
59
|
+
it.func = async function (s) {
|
|
60
|
+
const { testFS } = s;
|
|
61
|
+
let fName = 'non-existing-folder';
|
|
62
|
+
expect(await testFS.checkFolderPresence(fName)).toBe(false);
|
|
63
|
+
try {
|
|
64
|
+
await testFS.v.listFolder(fName);
|
|
65
|
+
fail('listing should fail for non-existing folder');
|
|
66
|
+
}
|
|
67
|
+
catch (exc) {
|
|
68
|
+
expect(exc.notFound).toBe(true);
|
|
69
|
+
}
|
|
70
|
+
await testFS.writeTxtFile(fName, '123');
|
|
71
|
+
expect(await testFS.checkFilePresence(fName)).toBe(true);
|
|
72
|
+
try {
|
|
73
|
+
await testFS.listFolder(fName);
|
|
74
|
+
fail('listing should fail on path that points to file');
|
|
75
|
+
}
|
|
76
|
+
catch (exc) {
|
|
77
|
+
expect(exc.notDirectory).toBe(true);
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
exports.specs.its.push(it);
|
|
81
|
+
it = { expectation: 'lists folder' };
|
|
82
|
+
it.func = async function (s) {
|
|
83
|
+
const { testFS } = s;
|
|
84
|
+
let fName = 'f1/f2';
|
|
85
|
+
await testFS.makeFolder('f1/f2');
|
|
86
|
+
await testFS.writeTxtFile(fName + '/file1', '');
|
|
87
|
+
await testFS.writeTxtFile(fName + '/folder1/file2', '');
|
|
88
|
+
await testFS.link(fName + '/link1', await testFS.readonlyFile(fName + '/folder1/file2'));
|
|
89
|
+
let { lst, version } = await testFS.v.listFolder(fName);
|
|
90
|
+
expect(Array.isArray(lst)).toBe(true);
|
|
91
|
+
expect(typeof version).toBe('number');
|
|
92
|
+
expect(lst.length).toBe(3);
|
|
93
|
+
for (let entry of lst) {
|
|
94
|
+
if (entry.isFile) {
|
|
95
|
+
expect(entry.name).toBe('file1');
|
|
96
|
+
}
|
|
97
|
+
else if (entry.isFolder) {
|
|
98
|
+
expect(entry.name).toBe('folder1');
|
|
99
|
+
}
|
|
100
|
+
else if (entry.isLink) {
|
|
101
|
+
expect(entry.name).toBe('link1');
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
fail(`folder listing has unknown type: ${JSON.stringify(entry, null, ' ')}`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
exports.specs.its.push(it);
|
|
109
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2022 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.specs = void 0;
|
|
20
|
+
exports.specs = {
|
|
21
|
+
description: '.v.listVersions',
|
|
22
|
+
its: []
|
|
23
|
+
};
|
|
24
|
+
let it = { expectation: 'fails on non-existing path' };
|
|
25
|
+
it.func = async function (s) {
|
|
26
|
+
const { testFS } = s;
|
|
27
|
+
const fName = 'non-existing-path';
|
|
28
|
+
await testFS.v.listVersions(fName).then(() => fail('should fail for non-existing folder'), exc => {
|
|
29
|
+
expect(exc.notFound).toBe(true);
|
|
30
|
+
});
|
|
31
|
+
};
|
|
32
|
+
exports.specs.its.push(it);
|
|
33
|
+
it = { expectation: `shows item's versions` };
|
|
34
|
+
it.func = async function (s) {
|
|
35
|
+
const { testFS } = s;
|
|
36
|
+
const folderPath = `some/dir`;
|
|
37
|
+
const filePath = `${folderPath}/file`;
|
|
38
|
+
const fileVer = await testFS.v.writeTxtFile(filePath, 'some');
|
|
39
|
+
let versions = await testFS.v.listVersions(filePath);
|
|
40
|
+
expect(versions.current).toBe(fileVer);
|
|
41
|
+
expect(versions.archived).toBeUndefined();
|
|
42
|
+
const folderVer = (await testFS.stat(folderPath)).version;
|
|
43
|
+
versions = await testFS.v.listVersions(folderPath);
|
|
44
|
+
expect(versions.current).toBe(folderVer);
|
|
45
|
+
expect(versions.archived).toBeUndefined();
|
|
46
|
+
};
|
|
47
|
+
exports.specs.its.push(it);
|
|
48
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016 - 2018, 2020 3NSoft Inc.
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify it under
|
|
6
|
+
the terms of the GNU General Public License as published by the Free Software
|
|
7
|
+
Foundation, either version 3 of the License, or (at your option) any later
|
|
8
|
+
version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
See the GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU General Public License along with
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.specs = void 0;
|
|
20
|
+
const random_node_1 = require("../../../../lib-common/random-node");
|
|
21
|
+
const bytes_equal_1 = require("../../../libs-for-tests/bytes-equal");
|
|
22
|
+
exports.specs = {
|
|
23
|
+
description: '.v.readBytes',
|
|
24
|
+
its: []
|
|
25
|
+
};
|
|
26
|
+
let it = { expectation: 'fails to read non-existent file' };
|
|
27
|
+
it.func = async function (s) {
|
|
28
|
+
const { testFS } = s;
|
|
29
|
+
let fName = 'unknown-file';
|
|
30
|
+
expect(await testFS.checkFilePresence(fName)).toBe(false);
|
|
31
|
+
try {
|
|
32
|
+
await testFS.v.readBytes(fName);
|
|
33
|
+
fail('reading bytes must fail, when file does not exist');
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
expect(err.notFound).toBe(true);
|
|
37
|
+
if (!err.notFound) {
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
exports.specs.its.push(it);
|
|
43
|
+
it = { expectation: 'reads whole file' };
|
|
44
|
+
it.func = async function (s) {
|
|
45
|
+
const { testFS } = s;
|
|
46
|
+
let originalBytes = (0, random_node_1.bytesSync)(12 * 1024 + 3);
|
|
47
|
+
let fName = 'file1';
|
|
48
|
+
let v1 = await testFS.v.writeBytes(fName, originalBytes);
|
|
49
|
+
let { bytes, version } = await testFS.v.readBytes(fName);
|
|
50
|
+
expect((0, bytes_equal_1.bytesEqual)(bytes, originalBytes)).withContext('file read should produce array with all bytes').toBe(true);
|
|
51
|
+
expect(version).withContext('file version at reading should be exactly the same as that on respective write').toBe(v1);
|
|
52
|
+
let v2 = await testFS.v.writeBytes(fName, new Uint8Array(0));
|
|
53
|
+
expect(v2).toBeGreaterThan(v1);
|
|
54
|
+
({ bytes, version } = await testFS.v.readBytes(fName));
|
|
55
|
+
expect(typeof bytes).withContext('reading empty file should produce undefined').toBe('undefined');
|
|
56
|
+
expect(version).withContext('file version at reading should be exactly the same as that on respective write').toBe(v2);
|
|
57
|
+
};
|
|
58
|
+
exports.specs.its.push(it);
|
|
59
|
+
it = { expectation: 'reads part of the file' };
|
|
60
|
+
it.func = async function (s) {
|
|
61
|
+
const { testFS } = s;
|
|
62
|
+
let fName = 'file3';
|
|
63
|
+
let originalBytes = (0, random_node_1.bytesSync)(12 * 1024 + 333);
|
|
64
|
+
let v = await testFS.v.writeBytes(fName, originalBytes);
|
|
65
|
+
let { bytes, version } = await testFS.v.readBytes(fName, 12, 3456);
|
|
66
|
+
expect((0, bytes_equal_1.bytesEqual)(bytes, originalBytes.subarray(12, 3456))).withContext('should read from a proper file interior').toBe(true);
|
|
67
|
+
expect(version).toBe(v);
|
|
68
|
+
({ bytes, version } = await testFS.v.readBytes(fName, 12 * 1024));
|
|
69
|
+
expect((0, bytes_equal_1.bytesEqual)(bytes, originalBytes.subarray(12 * 1024))).withContext('read should start from interior and go to file\'s end').toBe(true);
|
|
70
|
+
expect(version).toBe(v);
|
|
71
|
+
({ bytes, version } = await testFS.v.readBytes(fName, 12 * 1024, 1024 * 1024));
|
|
72
|
+
expect((0, bytes_equal_1.bytesEqual)(bytes, originalBytes.subarray(12 * 1024))).withContext('when end parameter is greater than file size, bytes up to files end must be read').toBe(true);
|
|
73
|
+
expect(version).toBe(v);
|
|
74
|
+
({ bytes, version } = await testFS.v.readBytes(fName, undefined, 123));
|
|
75
|
+
expect((0, bytes_equal_1.bytesEqual)(bytes, originalBytes)).withContext('when start parameter is not given, end should also be ignored').toBe(true);
|
|
76
|
+
expect(version).toBe(v);
|
|
77
|
+
({ bytes, version } = await testFS.v.readBytes(fName, 1024 * 1024, 1024 * 1024 + 4));
|
|
78
|
+
expect(bytes).withContext('when start is greater than file size, undefined must be returned').toBeUndefined();
|
|
79
|
+
expect(version).toBe(v);
|
|
80
|
+
({ bytes, version } = await testFS.v.readBytes(fName, 1024 * 1024));
|
|
81
|
+
expect(bytes).withContext('when start is greater than file size, undefined must be returned').toBeUndefined();
|
|
82
|
+
expect(version).toBe(v);
|
|
83
|
+
await testFS.readBytes(fName, -1).then(() => fail('negative parameters should cause throwing up'), () => { });
|
|
84
|
+
await testFS.readBytes(fName, 1, -2).then(() => fail('negative parameters should cause throwing up'), () => { });
|
|
85
|
+
({ bytes, version } = await testFS.v.readBytes(fName, 1234, 100));
|
|
86
|
+
expect(bytes).withContext('when end is smaller than start , undefined must be returned').toBeUndefined();
|
|
87
|
+
expect(version).toBe(v);
|
|
88
|
+
};
|
|
89
|
+
exports.specs.its.push(it);
|
|
90
|
+
Object.freeze(exports);
|