museria 0.2.49 → 0.3.2
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/.eslintrc +10 -2
- package/.github/workflows/build.yml +3 -3
- package/.github/workflows/publish.yml +3 -3
- package/README.md +55 -59
- package/bin/actions.js +28 -28
- package/bin/index.js +4 -4
- package/bin/runner.js +1 -1
- package/bin/utils.js +6 -2
- package/dist/client/museria.client.js +7 -7
- package/dist/face/45a265d0f07b31cde85f.ttf +0 -0
- package/dist/face/6205fd00fb1b573e9f0f.ttf +0 -0
- package/dist/face/8d3cabfc66809162fb4d.woff2 +0 -0
- package/dist/face/fb8184add5a3101ad0a3.woff2 +0 -0
- package/dist/face/museria.face.js +33 -13
- package/dist/face/style.css +13 -11
- package/package.json +41 -40
- package/src/browser/client/index.js +2 -1
- package/src/browser/face/client.js +2 -1
- package/src/browser/face/controllers/app/app.html +77 -69
- package/src/browser/face/controllers/app/app.js +14 -7
- package/src/browser/face/controllers/app/app.scss +2 -22
- package/src/browser/face/index.js +3 -3
- package/src/browser/face/styles/main.scss +91 -11
- package/src/browser/face/styles/vars.scss +0 -1
- package/src/client.js +73 -74
- package/src/collection/transports/music/index.js +20 -18
- package/src/db/transports/database/index.js +7 -5
- package/src/db/transports/loki/index.js +30 -25
- package/src/errors.js +2 -1
- package/src/index.js +8 -6
- package/src/node.js +312 -323
- package/src/schema.js +27 -29
- package/src/server/transports/express/api/butler/controllers.js +7 -10
- package/src/server/transports/express/api/butler/routes.js +5 -5
- package/src/server/transports/express/api/master/controllers.js +7 -10
- package/src/server/transports/express/api/master/routes.js +5 -5
- package/src/server/transports/express/api/node/controllers.js +52 -61
- package/src/server/transports/express/api/node/routes.js +10 -10
- package/src/server/transports/express/api/routes.js +1 -1
- package/src/server/transports/express/api/slave/controllers.js +7 -10
- package/src/server/transports/express/api/slave/routes.js +6 -6
- package/src/server/transports/express/client/controllers.js +40 -61
- package/src/server/transports/express/client/routes.js +33 -39
- package/src/server/transports/express/controllers.js +10 -21
- package/src/server/transports/express/index.js +23 -20
- package/src/server/transports/express/midds.js +67 -67
- package/src/server/transports/express/routes.js +12 -12
- package/src/utils.js +175 -184
- package/test/client.js +311 -305
- package/test/db/database.js +32 -28
- package/test/db/loki.js +78 -74
- package/test/group.js +161 -156
- package/test/index.js +20 -10
- package/test/node.js +461 -460
- package/test/routes.js +404 -399
- package/test/server/express.js +35 -31
- package/test/services.js +25 -18
- package/test/tools.js +8 -6
- package/test/utils.js +236 -234
- package/webpack.client.js +9 -7
- package/webpack.face.js +8 -6
- package/dist/face/fa-brands-400.eot +0 -0
- package/dist/face/fa-brands-400.svg +0 -3717
- package/dist/face/fa-brands-400.ttf +0 -0
- package/dist/face/fa-brands-400.woff +0 -0
- package/dist/face/fa-brands-400.woff2 +0 -0
- package/dist/face/fa-solid-900.eot +0 -0
- package/dist/face/fa-solid-900.svg +0 -5034
- package/dist/face/fa-solid-900.ttf +0 -0
- package/dist/face/fa-solid-900.woff +0 -0
- package/dist/face/fa-solid-900.woff2 +0 -0
- /package/dist/face/{open-sans.ttf → 17e98b9e5586529b13cc.ttf} +0 -0
- /package/dist/face/{proxima-nova.ttf → 326601dfabd91e3f016c.ttf} +0 -0
- /package/dist/face/{logo.svg → ee9c6af64aa224827cec.svg} +0 -0
package/test/db/database.js
CHANGED
@@ -1,37 +1,41 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
import { assert } from "chai";
|
2
|
+
import database from "../../src/db/transports/database/index.js";
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
describe('
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
const DatabaseMuseria = database();
|
5
|
+
|
6
|
+
export default function () {
|
7
|
+
describe('DatabaseMetastocle', () => {
|
8
|
+
let db;
|
9
|
+
|
10
|
+
describe('instance creation', function () {
|
11
|
+
it('should create an instance', function () {
|
12
|
+
assert.doesNotThrow(() => db = new DatabaseMuseria());
|
13
|
+
db.node = this.node;
|
14
|
+
});
|
11
15
|
});
|
12
|
-
});
|
13
16
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
17
|
+
describe('.init()', function () {
|
18
|
+
it('should not throw an exception', async function () {
|
19
|
+
await db.init();
|
20
|
+
});
|
21
|
+
});
|
19
22
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
+
describe('.deinit()', function () {
|
24
|
+
it('should not throw an exception', async function () {
|
25
|
+
await db.deinit();
|
26
|
+
});
|
23
27
|
});
|
24
|
-
});
|
25
28
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
+
describe('reinitialization', () => {
|
30
|
+
it('should not throw an exception', async function () {
|
31
|
+
await db.init();
|
32
|
+
});
|
29
33
|
});
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
34
|
+
|
35
|
+
describe('.destroy()', function () {
|
36
|
+
it('should not throw an exception', async function () {
|
37
|
+
await db.destroy();
|
38
|
+
});
|
35
39
|
});
|
36
40
|
});
|
37
|
-
}
|
41
|
+
}
|
package/test/db/loki.js
CHANGED
@@ -1,94 +1,98 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
import { assert } from "chai";
|
2
|
+
import tools from "../tools.js";
|
3
|
+
import loki from "../../src/db/transports/loki/index.js";
|
4
|
+
import utils from "../../src/utils.js";
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
assert.doesNotThrow(() => loki = new DatabaseLokiMuseria({
|
13
|
-
filename: tools.getDbFilePath(this.node)
|
14
|
-
}));
|
15
|
-
loki.node = this.node;
|
16
|
-
lastNodeDb = this.node.db;
|
17
|
-
this.node.db = loki;
|
18
|
-
});
|
19
|
-
});
|
6
|
+
const DatabaseLokiMuseria = loki();
|
7
|
+
|
8
|
+
export default function () {
|
9
|
+
describe('DatabaseLokiMetastocle', () => {
|
10
|
+
let loki;
|
11
|
+
let lastNodeDb;
|
20
12
|
|
21
|
-
|
22
|
-
|
23
|
-
|
13
|
+
describe('instance creation', function () {
|
14
|
+
it('should create an instance', function () {
|
15
|
+
assert.doesNotThrow(() => loki = new DatabaseLokiMuseria({
|
16
|
+
filename: tools.getDbFilePath(this.node)
|
17
|
+
}));
|
18
|
+
loki.node = this.node;
|
19
|
+
lastNodeDb = this.node.db;
|
20
|
+
this.node.db = loki;
|
21
|
+
});
|
24
22
|
});
|
25
23
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
describe('.init()', function () {
|
25
|
+
it('should not throw an exception', async function () {
|
26
|
+
await loki.init();
|
27
|
+
});
|
30
28
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
await loki.addMusicDocument({ title: title + '0' });
|
35
|
-
await loki.addMusicDocument({ title: title + '1' });
|
36
|
-
await loki.addMusicDocument({ title: title + '2' });
|
37
|
-
const docStrict = await loki.getMusicByPk(title + '1');
|
38
|
-
const doc = await loki.getMusicByPk(title + 'on');
|
39
|
-
assert.equal(docStrict.title, utils.beautifySongTitle(title + '1'), 'check the strict document');
|
40
|
-
assert.isObject(doc, 'check the approximate document');
|
29
|
+
it('should create a music collection', async function () {
|
30
|
+
await loki.addCollection('music', { pk: 'title', loki: { unique: ['fileHash'] } });
|
31
|
+
});
|
41
32
|
});
|
42
33
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
34
|
+
describe('.getMusicByPk()', function () {
|
35
|
+
it('should return the document', async function () {
|
36
|
+
const title = 'artist - title';
|
37
|
+
await loki.addMusicDocument({ title: title + '0' });
|
38
|
+
await loki.addMusicDocument({ title: title + '1' });
|
39
|
+
await loki.addMusicDocument({ title: title + '2' });
|
40
|
+
const docStrict = await loki.getMusicByPk(title + '1');
|
41
|
+
const doc = await loki.getMusicByPk(title + 'on');
|
42
|
+
assert.equal(docStrict.title, utils.beautifySongTitle(title + '1'), 'check the strict document');
|
43
|
+
assert.isObject(doc, 'check the approximate document');
|
44
|
+
});
|
47
45
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
await loki.addMusicDocument({ title: 'it - is a song', fileHash: hash });
|
52
|
-
const doc = await loki.getMusicByFileHash(hash);
|
53
|
-
assert.equal(doc.fileHash, hash);
|
46
|
+
it('should return null', async function () {
|
47
|
+
assert.isNull(await loki.getMusicByPk('wrong'));
|
48
|
+
});
|
54
49
|
});
|
55
50
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
51
|
+
describe('.getMusicByFileHash()', function () {
|
52
|
+
it('should get the right document', async function () {
|
53
|
+
const hash = 'y';
|
54
|
+
await loki.addMusicDocument({ title: 'it - is a song', fileHash: hash });
|
55
|
+
const doc = await loki.getMusicByFileHash(hash);
|
56
|
+
assert.equal(doc.fileHash, hash);
|
57
|
+
});
|
60
58
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
await loki.removeMusicByFileHash('x');
|
65
|
-
assert.equal(count, await loki.getCollectionSize('music'));
|
59
|
+
it('should return null', async function () {
|
60
|
+
assert.isNull(await loki.getMusicByFileHash('wrong'));
|
61
|
+
});
|
66
62
|
});
|
67
63
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
64
|
+
describe('.removeMusicByFileHash()', function () {
|
65
|
+
it('should not remove anything', async function () {
|
66
|
+
const count = await loki.getCollectionSize('music');
|
67
|
+
await loki.removeMusicByFileHash('x');
|
68
|
+
assert.equal(count, await loki.getCollectionSize('music'));
|
69
|
+
});
|
70
|
+
|
71
|
+
it('should remove only the necessary document', async function () {
|
72
|
+
const count = await loki.getCollectionSize('music');
|
73
|
+
await loki.addMusicDocument({ title: 'new - song', fileHash: 'x' });
|
74
|
+
await loki.removeMusicByFileHash('x');
|
75
|
+
assert.equal(count, await loki.getCollectionSize('music'));
|
76
|
+
});
|
73
77
|
});
|
74
|
-
});
|
75
78
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
+
describe('.deinit()', function () {
|
80
|
+
it('should not throw an exception', async function () {
|
81
|
+
await loki.deinit();
|
82
|
+
});
|
79
83
|
});
|
80
|
-
});
|
81
84
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
+
describe('reinitialization', () => {
|
86
|
+
it('should not throw an exception', async function () {
|
87
|
+
await loki.init();
|
88
|
+
});
|
85
89
|
});
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
90
|
+
|
91
|
+
describe('.destroy()', function () {
|
92
|
+
it('should not throw an exception', async function () {
|
93
|
+
await loki.destroy();
|
94
|
+
this.node.db = lastNodeDb;
|
95
|
+
});
|
92
96
|
});
|
93
97
|
});
|
94
|
-
}
|
98
|
+
}
|
package/test/group.js
CHANGED
@@ -1,168 +1,173 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
fileStoringNodeTimeout
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
}
|
44
|
-
});
|
45
|
-
|
46
|
-
it('should add the song', async () => {
|
47
|
-
const title = 'artist - title';
|
48
|
-
await utils.setSongTags(filePath, { fullTitle: title });
|
49
|
-
await client.addSong(filePath);
|
50
|
-
await tools.wait(fileStoringNodeTimeout);
|
51
|
-
let count = 0;
|
52
|
-
|
53
|
-
for(let i = 0; i < nodes.length; i++) {
|
54
|
-
const node = nodes[i];
|
55
|
-
const doc = await node.db.getMusicByPk(title);
|
56
|
-
doc && await node.hasFile(doc.fileHash) && count++;
|
57
|
-
}
|
58
|
-
|
59
|
-
assert.equal(count, duplicates);
|
60
|
-
});
|
61
|
-
|
62
|
-
it('should not add the existent songs again', async () => {
|
63
|
-
const title = 'artist - title';
|
64
|
-
await utils.setSongTags(filePath, { fullTitle: title });
|
65
|
-
await client.addSong(filePath);
|
66
|
-
await tools.wait(fileStoringNodeTimeout);
|
67
|
-
let count = 0;
|
68
|
-
|
69
|
-
for(let i = 0; i < nodes.length; i++) {
|
70
|
-
const node = nodes[i];
|
71
|
-
const doc = await node.db.getMusicByPk(title);
|
72
|
-
doc && await node.hasFile(doc.fileHash) && count++;
|
73
|
-
}
|
74
|
-
|
75
|
-
assert.equal(count, duplicates);
|
76
|
-
});
|
77
|
-
|
78
|
-
it('should not add the similar songs again', async () => {
|
79
|
-
const title = 'artists - title';
|
80
|
-
await utils.setSongTags(filePath, { fullTitle: title });
|
81
|
-
await client.addSong(filePath);
|
82
|
-
await tools.wait(fileStoringNodeTimeout);
|
83
|
-
let count = 0;
|
84
|
-
|
85
|
-
for(let i = 0; i < nodes.length; i++) {
|
86
|
-
const node = nodes[i];
|
87
|
-
const doc = await node.db.getMusicByPk(title);
|
88
|
-
doc && await node.hasFile(doc.fileHash) && count++;
|
89
|
-
}
|
90
|
-
|
91
|
-
assert.equal(count, duplicates);
|
92
|
-
});
|
1
|
+
import { assert } from "chai";
|
2
|
+
import fse from "fs-extra";
|
3
|
+
import path from "path";
|
4
|
+
import node from "../src/node.js";
|
5
|
+
import client from "../src/client.js";
|
6
|
+
import utils from "../src/utils.js";
|
7
|
+
import tools from "./tools.js";
|
8
|
+
|
9
|
+
const Node = node();
|
10
|
+
const Client = client();
|
11
|
+
|
12
|
+
export default function () {
|
13
|
+
describe('group communication', () => {
|
14
|
+
let nodes;
|
15
|
+
let client;
|
16
|
+
let filePath;
|
17
|
+
let duplicates;
|
18
|
+
let fileStoringNodeTimeout;
|
19
|
+
|
20
|
+
before(async () => {
|
21
|
+
nodes = [];
|
22
|
+
fileStoringNodeTimeout = 1000;
|
23
|
+
|
24
|
+
for (let i = 0; i < 4; i++) {
|
25
|
+
const node = new Node(await tools.createNodeOptions({ request: { fileStoringNodeTimeout } }));
|
26
|
+
await node.init();
|
27
|
+
nodes.push(node);
|
28
|
+
node.initialNetworkAddress = nodes[0].address;
|
29
|
+
}
|
30
|
+
|
31
|
+
client = new Client(await tools.createClientOptions({ address: nodes[0].address }));
|
32
|
+
await client.init();
|
33
|
+
await tools.nodesSync(nodes, nodes.length * 3);
|
34
|
+
filePath = path.join(tools.tmpPath, 'audio.mp3');
|
35
|
+
duplicates = await nodes[0].getFileDuplicatesCount();
|
36
|
+
});
|
37
|
+
|
38
|
+
after(async () => {
|
39
|
+
for (let i = 0; i < nodes.length; i++) {
|
40
|
+
await nodes[i].deinit();
|
41
|
+
}
|
42
|
+
});
|
93
43
|
|
94
|
-
|
95
|
-
|
44
|
+
it('should get the right network size', async () => {
|
45
|
+
for (let i = 0; i < nodes.length; i++) {
|
46
|
+
assert.equal(await nodes[i].getNetworkSize(), nodes.length);
|
47
|
+
}
|
48
|
+
});
|
49
|
+
|
50
|
+
it('should add the song', async () => {
|
51
|
+
const title = 'artist - title';
|
52
|
+
await utils.setSongTags(filePath, { fullTitle: title });
|
53
|
+
await client.addSong(filePath);
|
54
|
+
await tools.wait(fileStoringNodeTimeout);
|
55
|
+
let count = 0;
|
56
|
+
|
57
|
+
for (let i = 0; i < nodes.length; i++) {
|
58
|
+
const node = nodes[i];
|
59
|
+
const doc = await node.db.getMusicByPk(title);
|
60
|
+
doc && await node.hasFile(doc.fileHash) && count++;
|
61
|
+
}
|
96
62
|
|
97
|
-
|
98
|
-
|
99
|
-
|
63
|
+
assert.equal(count, duplicates);
|
64
|
+
});
|
65
|
+
|
66
|
+
it('should not add the existent songs again', async () => {
|
67
|
+
const title = 'artist - title';
|
68
|
+
await utils.setSongTags(filePath, { fullTitle: title });
|
69
|
+
await client.addSong(filePath);
|
70
|
+
await tools.wait(fileStoringNodeTimeout);
|
71
|
+
let count = 0;
|
72
|
+
|
73
|
+
for (let i = 0; i < nodes.length; i++) {
|
74
|
+
const node = nodes[i];
|
75
|
+
const doc = await node.db.getMusicByPk(title);
|
76
|
+
doc && await node.hasFile(doc.fileHash) && count++;
|
77
|
+
}
|
100
78
|
|
101
|
-
|
102
|
-
|
103
|
-
|
79
|
+
assert.equal(count, duplicates);
|
80
|
+
});
|
81
|
+
|
82
|
+
it('should not add the similar songs again', async () => {
|
83
|
+
const title = 'artists - title';
|
84
|
+
await utils.setSongTags(filePath, { fullTitle: title });
|
85
|
+
await client.addSong(filePath);
|
86
|
+
await tools.wait(fileStoringNodeTimeout);
|
87
|
+
let count = 0;
|
88
|
+
|
89
|
+
for (let i = 0; i < nodes.length; i++) {
|
90
|
+
const node = nodes[i];
|
91
|
+
const doc = await node.db.getMusicByPk(title);
|
92
|
+
doc && await node.hasFile(doc.fileHash) && count++;
|
104
93
|
}
|
105
|
-
}
|
106
94
|
|
107
|
-
|
108
|
-
|
109
|
-
|
95
|
+
assert.equal(count, duplicates);
|
96
|
+
});
|
97
|
+
|
98
|
+
it('should add the necessary count of duplicates', async () => {
|
99
|
+
const title = 'artist - title';
|
100
|
+
|
101
|
+
for (let i = 0; i < nodes.length; i++) {
|
102
|
+
const node = nodes[i];
|
103
|
+
const doc = await node.db.getMusicByPk(title);
|
104
|
+
|
105
|
+
if (doc) {
|
106
|
+
await node.removeFileFromStorage(doc.fileHash);
|
107
|
+
break;
|
108
|
+
}
|
109
|
+
}
|
110
110
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
111
|
+
await client.addSong(filePath);
|
112
|
+
await tools.wait(fileStoringNodeTimeout);
|
113
|
+
let count = 0;
|
114
|
+
|
115
|
+
for (let i = 0; i < nodes.length; i++) {
|
116
|
+
const node = nodes[i];
|
117
|
+
const doc = await node.db.getMusicByPk(title);
|
118
|
+
doc && await node.hasFile(doc.fileHash) && count++;
|
119
|
+
}
|
116
120
|
|
117
|
-
|
118
|
-
|
121
|
+
assert.equal(count, duplicates);
|
122
|
+
});
|
123
|
+
|
124
|
+
it('should return the right links', async () => {
|
125
|
+
const info = await client.getSongInfo('artist - title');
|
126
|
+
assert.equal(info.length, duplicates);
|
127
|
+
});
|
128
|
+
|
129
|
+
it('should remove the song', async () => {
|
130
|
+
const title = 'artist - title';
|
131
|
+
await client.removeSong(title);
|
132
|
+
let count = 0;
|
133
|
+
|
134
|
+
for (let i = 0; i < nodes.length; i++) {
|
135
|
+
const node = nodes[i];
|
136
|
+
const doc = await node.db.getMusicByPk(title);
|
137
|
+
doc && await node.hasFile(doc.fileHash) && count++;
|
138
|
+
}
|
119
139
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
140
|
+
assert.equal(count, 0);
|
141
|
+
});
|
142
|
+
|
143
|
+
it('should add songs in parallel', async () => {
|
144
|
+
const length = 6;
|
145
|
+
const p = [];
|
146
|
+
let fCount = 0;
|
147
|
+
let dCount = 0;
|
148
|
+
|
149
|
+
for (let i = 0; i < length; i++) {
|
150
|
+
const newPath = path.join(tools.tmpPath, `audio${i}.mp3`);
|
151
|
+
await fse.copy(filePath, newPath);
|
152
|
+
const tags = { fullTitle: `${Math.random()} - ${Math.random()}` };
|
153
|
+
await utils.setSongTags(newPath, tags);
|
154
|
+
}
|
124
155
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
let count = 0;
|
156
|
+
for (let i = 0; i < length; i++) {
|
157
|
+
p.push(client.addSong(path.join(tools.tmpPath, `audio${i}.mp3`)));
|
158
|
+
}
|
129
159
|
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
160
|
+
await Promise.all(p);
|
161
|
+
await tools.wait(fileStoringNodeTimeout * 2);
|
162
|
+
|
163
|
+
for (let i = 0; i < nodes.length; i++) {
|
164
|
+
const node = nodes[i];
|
165
|
+
fCount += await node.db.getData('filesCount');
|
166
|
+
dCount += await node.db.getCollectionSize('music');
|
167
|
+
}
|
135
168
|
|
136
|
-
|
169
|
+
assert.isOk(fCount >= length * duplicates, 'check the files');
|
170
|
+
assert.isOk(dCount >= length * duplicates, 'check the documents');
|
171
|
+
});
|
137
172
|
});
|
138
|
-
|
139
|
-
it('should add songs in parallel', async () => {
|
140
|
-
const length = 6;
|
141
|
-
const p = [];
|
142
|
-
let fCount = 0;
|
143
|
-
let dCount = 0;
|
144
|
-
|
145
|
-
for(let i = 0; i < length; i++) {
|
146
|
-
const newPath = path.join(tools.tmpPath, `audio${i}.mp3`);
|
147
|
-
await fse.copy(filePath, newPath);
|
148
|
-
const tags = { fullTitle: `${ Math.random() } - ${ Math.random() }` };
|
149
|
-
await utils.setSongTags(newPath, tags);
|
150
|
-
}
|
151
|
-
|
152
|
-
for(let i = 0; i < length; i++) {
|
153
|
-
p.push(client.addSong(path.join(tools.tmpPath, `audio${i}.mp3`)));
|
154
|
-
}
|
155
|
-
|
156
|
-
await Promise.all(p);
|
157
|
-
await tools.wait(fileStoringNodeTimeout * 2);
|
158
|
-
|
159
|
-
for(let i = 0; i < nodes.length; i++) {
|
160
|
-
const node = nodes[i];
|
161
|
-
fCount += await node.db.getData('filesCount');
|
162
|
-
dCount += await node.db.getCollectionSize('music');
|
163
|
-
}
|
164
|
-
|
165
|
-
assert.isOk(fCount >= length * duplicates, 'check the files');
|
166
|
-
assert.isOk(dCount >= length * duplicates, 'check the documents');
|
167
|
-
});
|
168
|
-
});
|
173
|
+
}
|
package/test/index.js
CHANGED
@@ -1,6 +1,16 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
import fse from "fs-extra";
|
2
|
+
import path from "path";
|
3
|
+
import tools from "./tools.js";
|
4
|
+
import { createRequire } from 'node:module';
|
5
|
+
import utils from "./utils.js";
|
6
|
+
import node from "./node.js";
|
7
|
+
|
8
|
+
import client from "./client.js";
|
9
|
+
import services from "./services.js";
|
10
|
+
import routes from "./routes.js";
|
11
|
+
import group from "./group.js";
|
12
|
+
|
13
|
+
const require = createRequire(import.meta.url);
|
4
14
|
|
5
15
|
describe('museria', () => {
|
6
16
|
before(async () => {
|
@@ -9,10 +19,10 @@ describe('museria', () => {
|
|
9
19
|
await fse.copy(require.resolve('./data/cover.jpg'), path.join(tools.tmpPath, 'cover.jpg'));
|
10
20
|
});
|
11
21
|
after(() => fse.remove(tools.tmpPath));
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
});
|
22
|
+
describe('utils', utils.bind(this));
|
23
|
+
describe('node', node.bind(this));
|
24
|
+
describe('client', client.bind(this));
|
25
|
+
describe('services', services.bind(this));
|
26
|
+
describe('routes', routes.bind(this));
|
27
|
+
describe('group', group.bind(this));
|
28
|
+
});
|