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,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
|
+
exports.specs = {
|
|
21
|
+
description: '.writableSubRoot',
|
|
22
|
+
its: []
|
|
23
|
+
};
|
|
24
|
+
let it = { expectation: 'creates sub-root based on existing folder' };
|
|
25
|
+
it.func = async function (s) {
|
|
26
|
+
const { testFS } = s;
|
|
27
|
+
const path = 'sub-root';
|
|
28
|
+
await testFS.makeFolder(path);
|
|
29
|
+
expect(await testFS.checkFolderPresence(path)).toBe(true);
|
|
30
|
+
const subRoot = await testFS.writableSubRoot(path);
|
|
31
|
+
expect(subRoot).toBeTruthy();
|
|
32
|
+
expect(subRoot.writable).toBe(true);
|
|
33
|
+
expect(!!subRoot.v).toBe(!!testFS.v);
|
|
34
|
+
const lst = await subRoot.listFolder('');
|
|
35
|
+
expect(Array.isArray(lst)).toBe(true);
|
|
36
|
+
};
|
|
37
|
+
exports.specs.its.push(it);
|
|
38
|
+
it = { expectation: 'creates new folder for a sub-root' };
|
|
39
|
+
it.func = async function (s) {
|
|
40
|
+
const { testFS } = s;
|
|
41
|
+
const path = 'sub-root2';
|
|
42
|
+
expect(await testFS.checkFolderPresence(path)).toBe(false);
|
|
43
|
+
const subRoot = await testFS.writableSubRoot(path);
|
|
44
|
+
expect(subRoot).toBeTruthy();
|
|
45
|
+
expect(subRoot.writable).toBe(true);
|
|
46
|
+
expect(!!subRoot.v).toBe(!!testFS.v);
|
|
47
|
+
const lst = await subRoot.listFolder('');
|
|
48
|
+
expect(Array.isArray(lst)).toBe(true);
|
|
49
|
+
};
|
|
50
|
+
exports.specs.its.push(it);
|
|
51
|
+
it = { expectation: 'creates parent folder(s) on the way' };
|
|
52
|
+
it.func = async function (s) {
|
|
53
|
+
const { testFS } = s;
|
|
54
|
+
const fName = 'sub-root';
|
|
55
|
+
const grParent = 'grand-parent';
|
|
56
|
+
const parent = 'grand-parent/parent';
|
|
57
|
+
const path = `${parent}/${fName}`;
|
|
58
|
+
expect(await testFS.checkFolderPresence(grParent)).toBe(false);
|
|
59
|
+
expect(await testFS.checkFolderPresence(parent)).toBe(false);
|
|
60
|
+
expect(await testFS.checkFolderPresence(path)).toBe(false);
|
|
61
|
+
const subRoot = await testFS.writableSubRoot(path);
|
|
62
|
+
expect(subRoot).toBeTruthy();
|
|
63
|
+
expect(subRoot.writable).toBe(true);
|
|
64
|
+
expect(!!subRoot.v).toBe(!!testFS.v);
|
|
65
|
+
const lst = await subRoot.listFolder('');
|
|
66
|
+
expect(Array.isArray(lst)).toBe(true);
|
|
67
|
+
expect(await testFS.checkFolderPresence(path)).toBe(true);
|
|
68
|
+
};
|
|
69
|
+
exports.specs.its.push(it);
|
|
70
|
+
it = {
|
|
71
|
+
expectation: `concurrently created (on the same folder) sub-roots access the same file tree`
|
|
72
|
+
};
|
|
73
|
+
it.func = async function (s) {
|
|
74
|
+
const { testFS } = s;
|
|
75
|
+
const subRootFolder = 'sub-root';
|
|
76
|
+
const promise1 = testFS.writableSubRoot(subRootFolder);
|
|
77
|
+
const promise2 = testFS.writableSubRoot(subRootFolder);
|
|
78
|
+
// create file in one fs
|
|
79
|
+
const fName = 'file 1';
|
|
80
|
+
const fileContent = `Sub-roots to the same folder should display same thing`;
|
|
81
|
+
const subRoot1 = await promise1;
|
|
82
|
+
await subRoot1.writeTxtFile(fName, fileContent);
|
|
83
|
+
// see that file is present via another fs
|
|
84
|
+
const subRoot2 = await promise2;
|
|
85
|
+
expect(await subRoot2.checkFilePresence(fName)).toBe(true);
|
|
86
|
+
const readContent = await subRoot2.readTxtFile(fName);
|
|
87
|
+
expect(readContent).toBe(fileContent);
|
|
88
|
+
};
|
|
89
|
+
exports.specs.its.push(it);
|
|
90
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2016, 2018, 2020, 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
|
+
const bytes_equal_1 = require("../../../libs-for-tests/bytes-equal");
|
|
22
|
+
exports.specs = {
|
|
23
|
+
description: '.writeBytes',
|
|
24
|
+
its: []
|
|
25
|
+
};
|
|
26
|
+
let it = { expectation: 'if not allowed to create, fails for missing file' };
|
|
27
|
+
it.func = async function (s) {
|
|
28
|
+
const { testFS } = s;
|
|
29
|
+
await testFS.writeBytes('non-existing-file', (0, random_node_1.bytesSync)(123), {})
|
|
30
|
+
.then(() => {
|
|
31
|
+
fail('should fail for missing file');
|
|
32
|
+
}, (e) => {
|
|
33
|
+
expect(e.notFound).toBe(true);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
exports.specs.its.push(it);
|
|
37
|
+
it = { expectation: 'creates file in existing folder' };
|
|
38
|
+
it.func = async function (s) {
|
|
39
|
+
const { testFS } = s;
|
|
40
|
+
let path = 'file1';
|
|
41
|
+
let content = (0, random_node_1.bytesSync)(2 * 1024);
|
|
42
|
+
expect(await testFS.checkFilePresence(path)).toBe(false);
|
|
43
|
+
await testFS.writeBytes(path, content);
|
|
44
|
+
expect(await testFS.checkFilePresence(path)).toBe(true);
|
|
45
|
+
let bytes = await testFS.readBytes(path);
|
|
46
|
+
expect((0, bytes_equal_1.bytesEqual)(content, bytes)).toBe(true);
|
|
47
|
+
};
|
|
48
|
+
exports.specs.its.push(it);
|
|
49
|
+
it = { expectation: 'creates parent folder(s) on the way' };
|
|
50
|
+
it.func = async function (s) {
|
|
51
|
+
const { testFS } = s;
|
|
52
|
+
let fName = 'file2';
|
|
53
|
+
let grParent = 'grand-parent';
|
|
54
|
+
let parent2 = 'grand-parent/parent2';
|
|
55
|
+
let path = `${parent2}/${fName}`;
|
|
56
|
+
expect(await testFS.checkFolderPresence(grParent)).toBe(false);
|
|
57
|
+
expect(await testFS.checkFolderPresence(parent2)).toBe(false);
|
|
58
|
+
expect(await testFS.checkFolderPresence(path)).toBe(false);
|
|
59
|
+
let content = (0, random_node_1.bytesSync)(2 * 1024);
|
|
60
|
+
await testFS.writeBytes(path, content);
|
|
61
|
+
expect(await testFS.checkFolderPresence(grParent)).toBe(true);
|
|
62
|
+
expect(await testFS.checkFolderPresence(parent2)).toBe(true);
|
|
63
|
+
expect(await testFS.checkFilePresence(path)).toBe(true);
|
|
64
|
+
let bytes = await testFS.readBytes(path);
|
|
65
|
+
expect((0, bytes_equal_1.bytesEqual)(content, bytes)).toBe(true);
|
|
66
|
+
};
|
|
67
|
+
exports.specs.its.push(it);
|
|
68
|
+
it = { expectation: 'over-writes existing file with a non-exclusive call' };
|
|
69
|
+
it.func = async function (s) {
|
|
70
|
+
const { testFS } = s;
|
|
71
|
+
let path = 'file3';
|
|
72
|
+
// setup initial file
|
|
73
|
+
let initBytes = (0, random_node_1.bytesSync)(123);
|
|
74
|
+
await testFS.writeBytes(path, initBytes);
|
|
75
|
+
expect(await testFS.checkFilePresence(path)).toBe(true);
|
|
76
|
+
let bytes = await testFS.readBytes(path);
|
|
77
|
+
expect((0, bytes_equal_1.bytesEqual)(initBytes, bytes)).toBe(true);
|
|
78
|
+
// write new file content
|
|
79
|
+
let newContent = (0, random_node_1.bytesSync)(3223);
|
|
80
|
+
await testFS.writeBytes(path, newContent);
|
|
81
|
+
expect(await testFS.checkFilePresence(path)).toBe(true);
|
|
82
|
+
bytes = await testFS.readBytes(path);
|
|
83
|
+
expect((0, bytes_equal_1.bytesEqual)(newContent, bytes)).toBe(true);
|
|
84
|
+
};
|
|
85
|
+
exports.specs.its.push(it);
|
|
86
|
+
it = { expectation: 'exclusive-create write throws when file already exists' };
|
|
87
|
+
it.func = async function (s) {
|
|
88
|
+
const { testFS } = s;
|
|
89
|
+
let path = 'file4';
|
|
90
|
+
// setup initial file
|
|
91
|
+
let initBytes = (0, random_node_1.bytesSync)(123);
|
|
92
|
+
await testFS.writeBytes(path, initBytes);
|
|
93
|
+
expect(await testFS.checkFilePresence(path)).toBe(true);
|
|
94
|
+
// try an exclusive write
|
|
95
|
+
let newContent = (0, random_node_1.bytesSync)(3223);
|
|
96
|
+
await testFS.writeBytes(path, newContent, { create: true, exclusive: true })
|
|
97
|
+
.then(() => {
|
|
98
|
+
fail('exclusive-create write operation must fail, when file exists.');
|
|
99
|
+
}, (exc) => {
|
|
100
|
+
expect(exc.alreadyExists).toBe(true);
|
|
101
|
+
});
|
|
102
|
+
let bytes = await testFS.readBytes(path);
|
|
103
|
+
expect((0, bytes_equal_1.bytesEqual)(initBytes, bytes)).withContext('initial file content stays intact').toBe(true);
|
|
104
|
+
};
|
|
105
|
+
exports.specs.its.push(it);
|
|
106
|
+
it = {
|
|
107
|
+
expectation: 'write big-ish file',
|
|
108
|
+
timeout: 10 * 1000
|
|
109
|
+
};
|
|
110
|
+
it.func = async function (s) {
|
|
111
|
+
const { testFS } = s;
|
|
112
|
+
let path = 'file5';
|
|
113
|
+
// write some bytes
|
|
114
|
+
let bytesToWrite = (0, random_node_1.bytesSync)(3000000);
|
|
115
|
+
await testFS.writeBytes(path, bytesToWrite);
|
|
116
|
+
expect(await testFS.checkFilePresence(path)).toBe(true);
|
|
117
|
+
// check that same bytes are read
|
|
118
|
+
let readBytes = await testFS.readBytes(path);
|
|
119
|
+
expect((0, bytes_equal_1.bytesEqual)(bytesToWrite, readBytes)).toBe(true);
|
|
120
|
+
};
|
|
121
|
+
exports.specs.its.push(it);
|
|
122
|
+
it = { expectation: 'writes 4K-even content' };
|
|
123
|
+
it.func = async function (s) {
|
|
124
|
+
const { testFS } = s;
|
|
125
|
+
const kb4 = 4 * 1024;
|
|
126
|
+
for (const [fName, contentLen] of [
|
|
127
|
+
['file-4kb', kb4],
|
|
128
|
+
['file-16kb', 4 * kb4],
|
|
129
|
+
['file-20kb', 5 * kb4],
|
|
130
|
+
]) {
|
|
131
|
+
const content = (0, random_node_1.bytesSync)(contentLen);
|
|
132
|
+
await testFS.writeBytes(fName, content);
|
|
133
|
+
expect((0, bytes_equal_1.bytesEqual)((await testFS.readBytes(fName)), content)).toBeTrue();
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
exports.specs.its.push(it);
|
|
137
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,101 @@
|
|
|
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: '.writeJSONFile',
|
|
23
|
+
its: []
|
|
24
|
+
};
|
|
25
|
+
let it = { expectation: 'if not allowed to create, fails for missing file' };
|
|
26
|
+
it.func = async function (s) {
|
|
27
|
+
const { testFS } = s;
|
|
28
|
+
let json = { a: 1, b: 2 };
|
|
29
|
+
await testFS.writeJSONFile('non-existing-file', json, {})
|
|
30
|
+
.then(() => {
|
|
31
|
+
fail('should fail for missing file');
|
|
32
|
+
}, (e) => {
|
|
33
|
+
expect(e.notFound).toBe(true);
|
|
34
|
+
});
|
|
35
|
+
};
|
|
36
|
+
exports.specs.its.push(it);
|
|
37
|
+
it = { expectation: 'creates file in existing folder' };
|
|
38
|
+
it.func = async function (s) {
|
|
39
|
+
const { testFS } = s;
|
|
40
|
+
let path = 'file1';
|
|
41
|
+
let json = { a: 1, b: 2 };
|
|
42
|
+
expect(await testFS.checkFilePresence(path)).toBe(false);
|
|
43
|
+
await testFS.writeJSONFile(path, json);
|
|
44
|
+
expect(await testFS.checkFilePresence(path)).toBe(true);
|
|
45
|
+
expect((0, json_equal_1.deepEqual)(json, await testFS.readJSONFile(path))).toBe(true);
|
|
46
|
+
};
|
|
47
|
+
exports.specs.its.push(it);
|
|
48
|
+
it = { expectation: 'creates parent folder(s) on the way' };
|
|
49
|
+
it.func = async function (s) {
|
|
50
|
+
const { testFS } = s;
|
|
51
|
+
let fName = 'file2';
|
|
52
|
+
let grParent = 'grand-parent';
|
|
53
|
+
let parent2 = 'grand-parent/parent2';
|
|
54
|
+
let path = `${parent2}/${fName}`;
|
|
55
|
+
expect(await testFS.checkFolderPresence(grParent)).toBe(false);
|
|
56
|
+
expect(await testFS.checkFolderPresence(parent2)).toBe(false);
|
|
57
|
+
expect(await testFS.checkFolderPresence(path)).toBe(false);
|
|
58
|
+
let json = { a: 'foo', b: true, 'df-df': 23 };
|
|
59
|
+
await testFS.writeJSONFile(path, json);
|
|
60
|
+
expect(await testFS.checkFolderPresence(grParent)).toBe(true);
|
|
61
|
+
expect(await testFS.checkFolderPresence(parent2)).toBe(true);
|
|
62
|
+
expect(await testFS.checkFilePresence(path)).toBe(true);
|
|
63
|
+
expect((0, json_equal_1.deepEqual)(json, await testFS.readJSONFile(path))).toBe(true);
|
|
64
|
+
};
|
|
65
|
+
exports.specs.its.push(it);
|
|
66
|
+
it = { expectation: 'over-writes existing file with a non-exclusive call' };
|
|
67
|
+
it.func = async function (s) {
|
|
68
|
+
const { testFS } = s;
|
|
69
|
+
let path = 'file3';
|
|
70
|
+
// setup initial file
|
|
71
|
+
let initJson = { a: 'foo', b: true, 'df-df': 23 };
|
|
72
|
+
await testFS.writeJSONFile(path, initJson);
|
|
73
|
+
expect(await testFS.checkFilePresence(path)).toBe(true);
|
|
74
|
+
expect((0, json_equal_1.deepEqual)(initJson, await testFS.readJSONFile(path))).toBe(true);
|
|
75
|
+
// write new file content
|
|
76
|
+
let newJson = null;
|
|
77
|
+
await testFS.writeJSONFile(path, newJson);
|
|
78
|
+
expect(await testFS.checkFilePresence(path)).toBe(true);
|
|
79
|
+
expect((0, json_equal_1.deepEqual)(newJson, await testFS.readJSONFile(path))).toBe(true);
|
|
80
|
+
};
|
|
81
|
+
exports.specs.its.push(it);
|
|
82
|
+
it = { expectation: 'exclusive-create write throws when file already exists' };
|
|
83
|
+
it.func = async function (s) {
|
|
84
|
+
const { testFS } = s;
|
|
85
|
+
let path = 'file4';
|
|
86
|
+
// setup initial file
|
|
87
|
+
let initJson = { a: 'foo', b: true, 'df-df': 23 };
|
|
88
|
+
await testFS.writeJSONFile(path, initJson);
|
|
89
|
+
expect(await testFS.checkFilePresence(path)).toBe(true);
|
|
90
|
+
// try an exclusive write
|
|
91
|
+
let newJson = null;
|
|
92
|
+
await testFS.writeJSONFile(path, newJson, { create: true, exclusive: true })
|
|
93
|
+
.then(() => {
|
|
94
|
+
fail('exclusive-create write operation must fail, when file exists.');
|
|
95
|
+
}, (exc) => {
|
|
96
|
+
expect(exc.alreadyExists).toBe(true);
|
|
97
|
+
});
|
|
98
|
+
expect((0, json_equal_1.deepEqual)(initJson, await testFS.readJSONFile(path))).withContext('initial file content stays intact').toBe(true);
|
|
99
|
+
};
|
|
100
|
+
exports.specs.its.push(it);
|
|
101
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
+
exports.specs = {
|
|
21
|
+
description: '.writeTxtFile',
|
|
22
|
+
its: []
|
|
23
|
+
};
|
|
24
|
+
let it = { expectation: 'if not allowed to create, fails for missing file' };
|
|
25
|
+
it.func = async function (s) {
|
|
26
|
+
const { testFS } = s;
|
|
27
|
+
let txt = 'Should I be at BlackHat conference or working?';
|
|
28
|
+
await testFS.writeTxtFile('non-existing-file', txt, {})
|
|
29
|
+
.then(() => {
|
|
30
|
+
fail('should fail for missing file');
|
|
31
|
+
}, (e) => {
|
|
32
|
+
expect(e.notFound).toBe(true);
|
|
33
|
+
});
|
|
34
|
+
};
|
|
35
|
+
exports.specs.its.push(it);
|
|
36
|
+
it = { expectation: 'creates file in existing folder' };
|
|
37
|
+
it.func = async function (s) {
|
|
38
|
+
const { testFS } = s;
|
|
39
|
+
let path = 'file1';
|
|
40
|
+
let txt = 'Should I be at BlackHat conference or working?';
|
|
41
|
+
expect(await testFS.checkFilePresence(path)).toBe(false);
|
|
42
|
+
await testFS.writeTxtFile(path, txt);
|
|
43
|
+
expect(await testFS.checkFilePresence(path)).toBe(true);
|
|
44
|
+
expect(await testFS.readTxtFile(path)).toBe(txt);
|
|
45
|
+
};
|
|
46
|
+
exports.specs.its.push(it);
|
|
47
|
+
it = { expectation: 'creates parent folder(s) on the way' };
|
|
48
|
+
it.func = async function (s) {
|
|
49
|
+
const { testFS } = s;
|
|
50
|
+
let fName = 'file2';
|
|
51
|
+
let grParent = 'grand-parent';
|
|
52
|
+
let parent2 = 'grand-parent/parent2';
|
|
53
|
+
let path = `${parent2}/${fName}`;
|
|
54
|
+
expect(await testFS.checkFolderPresence(grParent)).toBe(false);
|
|
55
|
+
expect(await testFS.checkFolderPresence(parent2)).toBe(false);
|
|
56
|
+
expect(await testFS.checkFolderPresence(path)).toBe(false);
|
|
57
|
+
let txt = 'Should I be at BlackHat conference or working?';
|
|
58
|
+
await testFS.writeTxtFile(path, txt);
|
|
59
|
+
expect(await testFS.checkFolderPresence(grParent)).toBe(true);
|
|
60
|
+
expect(await testFS.checkFolderPresence(parent2)).toBe(true);
|
|
61
|
+
expect(await testFS.checkFilePresence(path)).toBe(true);
|
|
62
|
+
expect(await testFS.readTxtFile(path)).toBe(txt);
|
|
63
|
+
};
|
|
64
|
+
exports.specs.its.push(it);
|
|
65
|
+
it = { expectation: 'over-writes existing file with a non-exclusive call' };
|
|
66
|
+
it.func = async function (s) {
|
|
67
|
+
const { testFS } = s;
|
|
68
|
+
let path = 'file3';
|
|
69
|
+
// setup initial file
|
|
70
|
+
let initTxt = 'Should I be at BlackHat conference or working?';
|
|
71
|
+
await testFS.writeTxtFile(path, initTxt);
|
|
72
|
+
expect(await testFS.checkFilePresence(path)).toBe(true);
|
|
73
|
+
expect(await testFS.readTxtFile(path)).toBe(initTxt);
|
|
74
|
+
// write new file content
|
|
75
|
+
let newTxt = 'Work gives tangible benefits.\nRetire and go anywhere.';
|
|
76
|
+
await testFS.writeTxtFile(path, newTxt);
|
|
77
|
+
expect(await testFS.checkFilePresence(path)).toBe(true);
|
|
78
|
+
expect(await testFS.readTxtFile(path)).toBe(newTxt);
|
|
79
|
+
};
|
|
80
|
+
exports.specs.its.push(it);
|
|
81
|
+
it = { expectation: 'exclusive-create write throws when file already exists' };
|
|
82
|
+
it.func = async function (s) {
|
|
83
|
+
const { testFS } = s;
|
|
84
|
+
let path = 'file4';
|
|
85
|
+
// setup initial file
|
|
86
|
+
let initTxt = 'Should I be at BlackHat conference or working?';
|
|
87
|
+
await testFS.writeTxtFile(path, initTxt);
|
|
88
|
+
expect(await testFS.checkFilePresence(path)).toBe(true);
|
|
89
|
+
// try an exclusive write
|
|
90
|
+
let newTxt = 'Work gives tangible benefits.\nRetire and go anywhere.';
|
|
91
|
+
await testFS.writeTxtFile(path, newTxt, { create: true, exclusive: true })
|
|
92
|
+
.then(() => {
|
|
93
|
+
fail('exclusive-create write operation must fail, when file exists.');
|
|
94
|
+
}, (exc) => {
|
|
95
|
+
expect(exc.alreadyExists).toBe(true);
|
|
96
|
+
});
|
|
97
|
+
expect(await testFS.readTxtFile(path)).withContext('initial file content stays intact').toBe(initTxt);
|
|
98
|
+
};
|
|
99
|
+
exports.specs.its.push(it);
|
|
100
|
+
Object.freeze(exports);
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 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.specs = void 0;
|
|
20
|
+
const random_node_1 = require("../../../../lib-common/random-node");
|
|
21
|
+
const json_equal_1 = require("../../../libs-for-tests/json-equal");
|
|
22
|
+
const deferred_1 = require("../../../../lib-common/processes/deferred");
|
|
23
|
+
exports.specs = {
|
|
24
|
+
description: '.v.sync.startedUpload',
|
|
25
|
+
its: []
|
|
26
|
+
};
|
|
27
|
+
let it = { expectation: 'fails to read non-existent path' };
|
|
28
|
+
it.func = async function (s) {
|
|
29
|
+
const { testFS } = s;
|
|
30
|
+
const fName = 'unknown-file';
|
|
31
|
+
expect(await testFS.checkFilePresence(fName)).toBe(false);
|
|
32
|
+
await testFS.v.sync.startUpload(fName)
|
|
33
|
+
.then(() => {
|
|
34
|
+
fail('reading status must fail, when path does not exist');
|
|
35
|
+
}, (err) => {
|
|
36
|
+
expect(err.notFound).toBeTrue();
|
|
37
|
+
if (!err.notFound) {
|
|
38
|
+
throw err;
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
};
|
|
42
|
+
exports.specs.its.push(it);
|
|
43
|
+
function collectFileUploadEvents(fs, path) {
|
|
44
|
+
const startEvent = (0, deferred_1.defer)();
|
|
45
|
+
const doneEvent = (0, deferred_1.defer)();
|
|
46
|
+
const unsub = fs.watchFile(path, {
|
|
47
|
+
next: ev => {
|
|
48
|
+
switch (ev.type) {
|
|
49
|
+
case 'upload-started':
|
|
50
|
+
startEvent.resolve(ev);
|
|
51
|
+
break;
|
|
52
|
+
case 'upload-done':
|
|
53
|
+
doneEvent.resolve(ev);
|
|
54
|
+
unsub();
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return {
|
|
60
|
+
startEvent: startEvent.promise,
|
|
61
|
+
doneEvent: doneEvent.promise
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
it = { expectation: 'uploads versions' };
|
|
65
|
+
it.func = async function (s) {
|
|
66
|
+
const { testFS } = s;
|
|
67
|
+
const file1 = 'some folder/file 1';
|
|
68
|
+
const v1 = await testFS.v.writeBytes(file1, await (0, random_node_1.bytes)(10));
|
|
69
|
+
let syncStatus = await testFS.v.sync.status(file1, true);
|
|
70
|
+
expect(syncStatus.state).toBe('unsynced');
|
|
71
|
+
expect(syncStatus.synced).toBeUndefined();
|
|
72
|
+
expect(syncStatus.local).toBeDefined();
|
|
73
|
+
expect(syncStatus.local.latest).toBe(v1);
|
|
74
|
+
// file version written as a whole
|
|
75
|
+
const v2 = await testFS.v.writeBytes(file1, await (0, random_node_1.bytes)(10));
|
|
76
|
+
syncStatus = await testFS.v.sync.status(file1, true);
|
|
77
|
+
expect(syncStatus.local.latest).toBe(v2);
|
|
78
|
+
try {
|
|
79
|
+
await testFS.v.sync.startUpload(file1, { localVersion: v1 });
|
|
80
|
+
fail(`Version ${v1} is not current can't be upload`);
|
|
81
|
+
}
|
|
82
|
+
catch (exc) {
|
|
83
|
+
expect(exc.type).toBe('fs-sync');
|
|
84
|
+
}
|
|
85
|
+
let events = collectFileUploadEvents(testFS, file1);
|
|
86
|
+
let startedUpload = await testFS.v.sync.startUpload(file1, { localVersion: v2 });
|
|
87
|
+
expect(startedUpload).withContext(`upload should be started`).toBeDefined();
|
|
88
|
+
expect(startedUpload.uploadVersion).withContext(`first uploaded version should be equal to 1`).toBe(1);
|
|
89
|
+
syncStatus = await testFS.v.sync.status(file1, true);
|
|
90
|
+
expect(syncStatus.uploading).toBeDefined();
|
|
91
|
+
expect(syncStatus.uploading.localVersion).toBe(v2);
|
|
92
|
+
expect(syncStatus.uploading.remoteVersion).toBe(startedUpload.uploadVersion);
|
|
93
|
+
// await upload events and completion
|
|
94
|
+
let startEvent = await events.startEvent;
|
|
95
|
+
expect(startEvent.type).toBe('upload-started');
|
|
96
|
+
expect(startEvent.uploadTaskId).toBe(startedUpload.uploadTaskId);
|
|
97
|
+
expect(startEvent.localVersion).toBe(v2);
|
|
98
|
+
expect(startEvent.uploadVersion).toBe(startedUpload.uploadVersion);
|
|
99
|
+
expect(startEvent.totalBytesToUpload).toBeGreaterThan(10);
|
|
100
|
+
await events.doneEvent;
|
|
101
|
+
syncStatus = await testFS.v.sync.status(file1, true);
|
|
102
|
+
expect(syncStatus.state).toBe('synced');
|
|
103
|
+
expect(syncStatus.uploading).toBeUndefined();
|
|
104
|
+
expect(syncStatus.synced).toBeDefined();
|
|
105
|
+
expect(syncStatus.local).toBeUndefined();
|
|
106
|
+
expect(syncStatus.synced.latest).toBe(startedUpload.uploadVersion);
|
|
107
|
+
expect((await testFS.stat(file1)).version).toBe(startedUpload.uploadVersion);
|
|
108
|
+
// file version written as a diff from a synced version
|
|
109
|
+
const { sink: sink3, version: v3 } = await testFS.v.getByteSink(file1, { truncate: false });
|
|
110
|
+
expect(v3).withContext(`normal increase of version by 1`).toBe(2);
|
|
111
|
+
await sink3.splice(10, 0, await (0, random_node_1.bytes)(10));
|
|
112
|
+
await sink3.done();
|
|
113
|
+
syncStatus = await testFS.v.sync.status(file1, true);
|
|
114
|
+
expect(syncStatus.local.latest).toBe(v3);
|
|
115
|
+
expect(syncStatus.uploading).toBeUndefined();
|
|
116
|
+
events = collectFileUploadEvents(testFS, file1);
|
|
117
|
+
// note upload of latest version, when version isn't given
|
|
118
|
+
startedUpload = await testFS.v.sync.startUpload(file1);
|
|
119
|
+
expect(startedUpload.uploadVersion)
|
|
120
|
+
.withContext(`next uploaded version increases by 1`)
|
|
121
|
+
.toBe(2);
|
|
122
|
+
syncStatus = await testFS.v.sync.status(file1, true);
|
|
123
|
+
expect(syncStatus.uploading)
|
|
124
|
+
.withContext(`started upload normally won't be fast to complete by this point`)
|
|
125
|
+
.toBeDefined();
|
|
126
|
+
expect(syncStatus.uploading.localVersion).toBe(v3);
|
|
127
|
+
expect(syncStatus.uploading.remoteVersion).toBe(2);
|
|
128
|
+
// watch and await upload completion
|
|
129
|
+
await events.doneEvent;
|
|
130
|
+
syncStatus = await testFS.v.sync.status(file1, true);
|
|
131
|
+
expect(syncStatus.uploading)
|
|
132
|
+
.withContext(`upload must be complete after watch end`)
|
|
133
|
+
.toBeUndefined();
|
|
134
|
+
// file version written as a diff from a synced version and diff of that
|
|
135
|
+
let sink = (await testFS.v.getByteSink(file1, { truncate: false })).sink;
|
|
136
|
+
await sink.splice(20, 0, await (0, random_node_1.bytes)(10));
|
|
137
|
+
await sink.done();
|
|
138
|
+
sink = (await testFS.v.getByteSink(file1, { truncate: false })).sink;
|
|
139
|
+
await sink.splice(25, 0, await (0, random_node_1.bytes)(10));
|
|
140
|
+
await sink.done();
|
|
141
|
+
syncStatus = await testFS.v.sync.status(file1, true);
|
|
142
|
+
expect(syncStatus.local.latest).toBe(v3 + 2);
|
|
143
|
+
events = collectFileUploadEvents(testFS, file1);
|
|
144
|
+
startedUpload = await testFS.v.sync.startUpload(file1);
|
|
145
|
+
expect(startedUpload.uploadVersion)
|
|
146
|
+
.withContext(`next uploaded version increases by 1`)
|
|
147
|
+
.toBe(3);
|
|
148
|
+
await events.doneEvent;
|
|
149
|
+
syncStatus = await testFS.v.sync.status(file1, true);
|
|
150
|
+
expect(syncStatus.uploading)
|
|
151
|
+
.withContext(`upload must be complete after watch end`)
|
|
152
|
+
.toBeUndefined();
|
|
153
|
+
// upload of uploaded is a noop
|
|
154
|
+
startedUpload = await testFS.v.sync.startUpload(file1);
|
|
155
|
+
expect(startedUpload)
|
|
156
|
+
.withContext(`noop returns undefined, as upload wasn't started`)
|
|
157
|
+
.toBeUndefined();
|
|
158
|
+
expect((0, json_equal_1.deepEqual)(syncStatus, await testFS.v.sync.status(file1, true)))
|
|
159
|
+
.withContext(`nothing changed with noop`)
|
|
160
|
+
.toBeTrue();
|
|
161
|
+
};
|
|
162
|
+
exports.specs.its.push(it);
|
|
163
|
+
const mb = 1024 * 1024;
|
|
164
|
+
it = { expectation: 'uploads big file versions', timeout: 10000 };
|
|
165
|
+
it.func = async function (s) {
|
|
166
|
+
const { testFS } = s;
|
|
167
|
+
const file1 = 'some folder/file 1';
|
|
168
|
+
// file version written as a whole
|
|
169
|
+
await testFS.v.writeBytes(file1, await (0, random_node_1.bytes)(3 * mb));
|
|
170
|
+
await testFS.v.sync.upload(file1);
|
|
171
|
+
let syncStatus = await testFS.v.sync.status(file1, true);
|
|
172
|
+
expect(syncStatus.synced.latest)
|
|
173
|
+
.withContext(`first uploaded version should be equal to 1`).toBe(1);
|
|
174
|
+
expect((await testFS.stat(file1)).version).toBe(1);
|
|
175
|
+
// file version written as a diff from a synced version
|
|
176
|
+
const { sink: sinkForV2, version: v2 } = await testFS.v.getByteSink(file1, { truncate: false });
|
|
177
|
+
expect(v2).withContext(`normal increase of version by 1`).toBe(2);
|
|
178
|
+
await sinkForV2.splice(2 * mb, 0, await (0, random_node_1.bytes)(2 * mb));
|
|
179
|
+
await sinkForV2.done();
|
|
180
|
+
await testFS.v.sync.upload(file1);
|
|
181
|
+
syncStatus = await testFS.v.sync.status(file1, true);
|
|
182
|
+
expect(syncStatus.synced.latest)
|
|
183
|
+
.withContext(`next uploaded version increases by 1`).toBe(2);
|
|
184
|
+
};
|
|
185
|
+
// XXX add this, when changed to proper event checking
|
|
186
|
+
// specs.its.push(it);
|
|
187
|
+
Object.freeze(exports);
|