-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.ts
49 lines (39 loc) · 1.41 KB
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
47
48
49
import { setupDb, dbRun } from './src/db';
import { getExistingFileEtags } from './src/etags';
import { sync, syncFile } from './src/sync';
const BUCKET = 'music-v0-studio';
const TEST_FOLDER = '_sync-test';
const TEST_DB_PATH = './dbs/test-sync.db';
const MUSIC_DIR = 'Z:\\Music\\Music';
test();
async function test() {
const db = await setupDb(TEST_DB_PATH);
await dbRun(db, `
CREATE TABLE IF NOT EXISTS sync_status (
path STRING PRIMARY KEY,
localPath STRING,
eTag STRING,
md5 STRING
)
`);
const testFile1 = '16bit\\Cobra\\01 Cobra.mp3';
const testFile2 = '3 Doors Down\\The Better Life\\2-13 Loser (live).m4a';
const testFile3 = 'Action Bronson & Alchemist\\Rare Chandeliers\\08 Modern Day Revelations feat Roc M.mp3';
const testFolder = '16bit';
const etags = await getExistingFileEtags(BUCKET, TEST_FOLDER);
await Promise.all([
syncFile(BUCKET, TEST_FOLDER, MUSIC_DIR, testFile1, etags, db),
syncFile(BUCKET, TEST_FOLDER, MUSIC_DIR, testFile2, etags, db),
syncFile(BUCKET, TEST_FOLDER, MUSIC_DIR, testFile3, etags, db),
]);
await sync(BUCKET, TEST_FOLDER, MUSIC_DIR, testFolder, etags, db, 16);
return new Promise((res, rej) => {
db.close(err => {
if (err) {
rej(err);
} else {
res(err);
}
});
});
}