|
|
|
|
@@ -1,6 +1,6 @@
|
|
|
|
|
import crypto from 'crypto';
|
|
|
|
|
import fs from 'fs';
|
|
|
|
|
import {Uint64BE} from 'int64-buffer';
|
|
|
|
|
import { Uint64BE } from 'int64-buffer';
|
|
|
|
|
|
|
|
|
|
import * as repertory from '../index.js';
|
|
|
|
|
import connection from '../networking/connection';
|
|
|
|
|
@@ -10,18 +10,18 @@ const TEST_HOST = process.env.TEST_HOST || 'localhost';
|
|
|
|
|
const TEST_PASSWORD = process.env.TEST_PASSWORD || '';
|
|
|
|
|
const TEST_PORT = process.env.TEST_PORT || 20000;
|
|
|
|
|
|
|
|
|
|
const calculate_sha256 = path => {
|
|
|
|
|
const calculate_sha256 = (path) => {
|
|
|
|
|
return new Promise((resolve, reject) => {
|
|
|
|
|
const hash = crypto.createHash('sha256');
|
|
|
|
|
|
|
|
|
|
fs.createReadStream(path)
|
|
|
|
|
.on('data', data => hash.update(data))
|
|
|
|
|
.on('error', err => reject(err))
|
|
|
|
|
.on('end', () => {
|
|
|
|
|
const h = hash.digest('hex');
|
|
|
|
|
console.log(path, h);
|
|
|
|
|
resolve(h);
|
|
|
|
|
});
|
|
|
|
|
.on('data', (data) => hash.update(data))
|
|
|
|
|
.on('error', (err) => reject(err))
|
|
|
|
|
.on('end', () => {
|
|
|
|
|
const h = hash.digest('hex');
|
|
|
|
|
console.log(path, h);
|
|
|
|
|
resolve(h);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@@ -43,8 +43,12 @@ test('can create a connection to repertory api', async () => {
|
|
|
|
|
|
|
|
|
|
test('create_pool returns a connection if pool size is <=1', async () => {
|
|
|
|
|
for (let i = 0; i < 2; i++) {
|
|
|
|
|
const conn =
|
|
|
|
|
await repertory.create_pool(i, TEST_HOST, TEST_PORT, TEST_PASSWORD);
|
|
|
|
|
const conn = await repertory.create_pool(
|
|
|
|
|
i,
|
|
|
|
|
TEST_HOST,
|
|
|
|
|
TEST_PORT,
|
|
|
|
|
TEST_PASSWORD
|
|
|
|
|
);
|
|
|
|
|
expect(conn).toBeInstanceOf(connection);
|
|
|
|
|
test_connection(conn, true);
|
|
|
|
|
|
|
|
|
|
@@ -53,8 +57,12 @@ test('create_pool returns a connection if pool size is <=1', async () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('can create a connection pool', async () => {
|
|
|
|
|
const conn =
|
|
|
|
|
await repertory.create_pool(2, TEST_HOST, TEST_PORT, TEST_PASSWORD);
|
|
|
|
|
const conn = await repertory.create_pool(
|
|
|
|
|
2,
|
|
|
|
|
TEST_HOST,
|
|
|
|
|
TEST_PORT,
|
|
|
|
|
TEST_PASSWORD
|
|
|
|
|
);
|
|
|
|
|
console.log(conn);
|
|
|
|
|
expect(conn).toBeInstanceOf(connection_pool);
|
|
|
|
|
expect(conn.host_or_ip).toEqual(TEST_HOST);
|
|
|
|
|
@@ -68,8 +76,12 @@ test('can create a connection pool', async () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('can get drive information using api', async () => {
|
|
|
|
|
const conn =
|
|
|
|
|
await repertory.create_pool(2, TEST_HOST, TEST_PORT, TEST_PASSWORD);
|
|
|
|
|
const conn = await repertory.create_pool(
|
|
|
|
|
2,
|
|
|
|
|
TEST_HOST,
|
|
|
|
|
TEST_PORT,
|
|
|
|
|
TEST_PASSWORD
|
|
|
|
|
);
|
|
|
|
|
const api = repertory.create_api(conn);
|
|
|
|
|
const di = await api.get_drive_information();
|
|
|
|
|
console.log(di);
|
|
|
|
|
@@ -82,8 +94,12 @@ test('can get drive information using api', async () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('can create and remove a directory using api', async () => {
|
|
|
|
|
const conn =
|
|
|
|
|
await repertory.create_pool(2, TEST_HOST, TEST_PORT, TEST_PASSWORD);
|
|
|
|
|
const conn = await repertory.create_pool(
|
|
|
|
|
2,
|
|
|
|
|
TEST_HOST,
|
|
|
|
|
TEST_PORT,
|
|
|
|
|
TEST_PASSWORD
|
|
|
|
|
);
|
|
|
|
|
const api = repertory.create_api(conn);
|
|
|
|
|
expect(await api.directory.create('/repertory_js')).toEqual(0);
|
|
|
|
|
expect(await api.directory.remove('/repertory_js')).toEqual(0);
|
|
|
|
|
@@ -92,8 +108,12 @@ test('can create and remove a directory using api', async () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('can get directory list and snapshot using api', async () => {
|
|
|
|
|
const conn =
|
|
|
|
|
await repertory.create_pool(2, TEST_HOST, TEST_PORT, TEST_PASSWORD);
|
|
|
|
|
const conn = await repertory.create_pool(
|
|
|
|
|
2,
|
|
|
|
|
TEST_HOST,
|
|
|
|
|
TEST_PORT,
|
|
|
|
|
TEST_PASSWORD
|
|
|
|
|
);
|
|
|
|
|
const api = repertory.create_api(conn);
|
|
|
|
|
|
|
|
|
|
const test_results = async (remote_path, page_count, get_page) => {
|
|
|
|
|
@@ -131,8 +151,12 @@ test('can get directory list and snapshot using api', async () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('can create, close and delete a file using api', async () => {
|
|
|
|
|
const conn =
|
|
|
|
|
await repertory.create_pool(2, TEST_HOST, TEST_PORT, TEST_PASSWORD);
|
|
|
|
|
const conn = await repertory.create_pool(
|
|
|
|
|
2,
|
|
|
|
|
TEST_HOST,
|
|
|
|
|
TEST_PORT,
|
|
|
|
|
TEST_PASSWORD
|
|
|
|
|
);
|
|
|
|
|
const api = repertory.create_api(conn);
|
|
|
|
|
const f = await api.file.create_or_open('/repertory_file.dat');
|
|
|
|
|
console.log(f);
|
|
|
|
|
@@ -149,8 +173,12 @@ test('can create, close and delete a file using api', async () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('can open, close and delete a file using api', async () => {
|
|
|
|
|
const conn =
|
|
|
|
|
await repertory.create_pool(2, TEST_HOST, TEST_PORT, TEST_PASSWORD);
|
|
|
|
|
const conn = await repertory.create_pool(
|
|
|
|
|
2,
|
|
|
|
|
TEST_HOST,
|
|
|
|
|
TEST_PORT,
|
|
|
|
|
TEST_PASSWORD
|
|
|
|
|
);
|
|
|
|
|
const api = repertory.create_api(conn);
|
|
|
|
|
let f = await api.file.create_or_open('/repertory_file.dat');
|
|
|
|
|
expect(await f.close()).toEqual(0);
|
|
|
|
|
@@ -170,8 +198,12 @@ test('can open, close and delete a file using api', async () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('can write to and read from a file using api', async () => {
|
|
|
|
|
const conn =
|
|
|
|
|
await repertory.create_pool(2, TEST_HOST, TEST_PORT, TEST_PASSWORD);
|
|
|
|
|
const conn = await repertory.create_pool(
|
|
|
|
|
2,
|
|
|
|
|
TEST_HOST,
|
|
|
|
|
TEST_PORT,
|
|
|
|
|
TEST_PASSWORD
|
|
|
|
|
);
|
|
|
|
|
const api = repertory.create_api(conn);
|
|
|
|
|
const f = await api.file.create_or_open('/repertory_file.dat');
|
|
|
|
|
|
|
|
|
|
@@ -193,8 +225,12 @@ test('can write to and read from a file using api', async () => {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
test('can truncate a file using api', async () => {
|
|
|
|
|
const conn =
|
|
|
|
|
await repertory.create_pool(2, TEST_HOST, TEST_PORT, TEST_PASSWORD);
|
|
|
|
|
const conn = await repertory.create_pool(
|
|
|
|
|
2,
|
|
|
|
|
TEST_HOST,
|
|
|
|
|
TEST_PORT,
|
|
|
|
|
TEST_PASSWORD
|
|
|
|
|
);
|
|
|
|
|
const api = repertory.create_api(conn);
|
|
|
|
|
const f = await api.file.create_or_open('/repertory_file.dat');
|
|
|
|
|
|
|
|
|
|
@@ -213,22 +249,34 @@ test('can truncate a file using api', async () => {
|
|
|
|
|
test('can upload and download a file using api', async () => {
|
|
|
|
|
try {
|
|
|
|
|
fs.unlinkSync('repertory_test.dat');
|
|
|
|
|
} catch {
|
|
|
|
|
}
|
|
|
|
|
} catch {}
|
|
|
|
|
|
|
|
|
|
const conn =
|
|
|
|
|
await repertory.create_pool(2, TEST_HOST, TEST_PORT, TEST_PASSWORD);
|
|
|
|
|
const conn = await repertory.create_pool(
|
|
|
|
|
2,
|
|
|
|
|
TEST_HOST,
|
|
|
|
|
TEST_PORT,
|
|
|
|
|
TEST_PASSWORD
|
|
|
|
|
);
|
|
|
|
|
const api = repertory.create_api(conn);
|
|
|
|
|
expect(await api.file.upload('test.dat', '/repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => { console.log(l, r, p, c); }))
|
|
|
|
|
.toBeTruthy();
|
|
|
|
|
expect(
|
|
|
|
|
await api.file.upload('test.dat', '/repertory_test.dat', (l, r, p, c) => {
|
|
|
|
|
console.log(l, r, p, c);
|
|
|
|
|
})
|
|
|
|
|
).toBeTruthy();
|
|
|
|
|
|
|
|
|
|
expect(await api.file.download('/repertory_test.dat', 'repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => { console.log(l, r, p, c); }))
|
|
|
|
|
.toBeTruthy();
|
|
|
|
|
expect(
|
|
|
|
|
await api.file.download(
|
|
|
|
|
'/repertory_test.dat',
|
|
|
|
|
'repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => {
|
|
|
|
|
console.log(l, r, p, c);
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
).toBeTruthy();
|
|
|
|
|
|
|
|
|
|
expect(await calculate_sha256('test.dat'))
|
|
|
|
|
.toEqual(await calculate_sha256('repertory_test.dat'));
|
|
|
|
|
expect(await calculate_sha256('test.dat')).toEqual(
|
|
|
|
|
await calculate_sha256('repertory_test.dat')
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(await api.file.delete('/repertory_test.dat')).toEqual(0);
|
|
|
|
|
fs.unlinkSync('repertory_test.dat');
|
|
|
|
|
@@ -237,21 +285,39 @@ test('can upload and download a file using api', async () => {
|
|
|
|
|
}, 60000);
|
|
|
|
|
|
|
|
|
|
test('can download and overwrite a file using api', async () => {
|
|
|
|
|
const conn =
|
|
|
|
|
await repertory.create_pool(2, TEST_HOST, TEST_PORT, TEST_PASSWORD);
|
|
|
|
|
const conn = await repertory.create_pool(
|
|
|
|
|
2,
|
|
|
|
|
TEST_HOST,
|
|
|
|
|
TEST_PORT,
|
|
|
|
|
TEST_PASSWORD
|
|
|
|
|
);
|
|
|
|
|
const api = repertory.create_api(conn);
|
|
|
|
|
expect(await api.file.upload('test.dat', '/repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => { console.log(l, r, p, c); }))
|
|
|
|
|
.toBeTruthy();
|
|
|
|
|
expect(
|
|
|
|
|
await api.file.upload('test.dat', '/repertory_test.dat', (l, r, p, c) => {
|
|
|
|
|
console.log(l, r, p, c);
|
|
|
|
|
})
|
|
|
|
|
).toBeTruthy();
|
|
|
|
|
|
|
|
|
|
expect(await api.file.download('/repertory_test.dat', 'repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => { console.log(l, r, p, c); }))
|
|
|
|
|
.toBeTruthy();
|
|
|
|
|
expect(
|
|
|
|
|
await api.file.download(
|
|
|
|
|
'/repertory_test.dat',
|
|
|
|
|
'repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => {
|
|
|
|
|
console.log(l, r, p, c);
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
).toBeTruthy();
|
|
|
|
|
|
|
|
|
|
expect(await api.file.download('/repertory_test.dat', 'repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => { console.log(l, r, p, c); },
|
|
|
|
|
true))
|
|
|
|
|
.toBeTruthy();
|
|
|
|
|
expect(
|
|
|
|
|
await api.file.download(
|
|
|
|
|
'/repertory_test.dat',
|
|
|
|
|
'repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => {
|
|
|
|
|
console.log(l, r, p, c);
|
|
|
|
|
},
|
|
|
|
|
true
|
|
|
|
|
)
|
|
|
|
|
).toBeTruthy();
|
|
|
|
|
|
|
|
|
|
expect(await api.file.delete('/repertory_test.dat')).toEqual(0);
|
|
|
|
|
fs.unlinkSync('repertory_test.dat');
|
|
|
|
|
@@ -260,21 +326,39 @@ test('can download and overwrite a file using api', async () => {
|
|
|
|
|
}, 60000);
|
|
|
|
|
|
|
|
|
|
test('download fails if overwrite is false using api', async () => {
|
|
|
|
|
const conn =
|
|
|
|
|
await repertory.create_pool(2, TEST_HOST, TEST_PORT, TEST_PASSWORD);
|
|
|
|
|
const conn = await repertory.create_pool(
|
|
|
|
|
2,
|
|
|
|
|
TEST_HOST,
|
|
|
|
|
TEST_PORT,
|
|
|
|
|
TEST_PASSWORD
|
|
|
|
|
);
|
|
|
|
|
const api = repertory.create_api(conn);
|
|
|
|
|
expect(await api.file.upload('test.dat', '/repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => { console.log(l, r, p, c); }))
|
|
|
|
|
.toBeTruthy();
|
|
|
|
|
expect(
|
|
|
|
|
await api.file.upload('test.dat', '/repertory_test.dat', (l, r, p, c) => {
|
|
|
|
|
console.log(l, r, p, c);
|
|
|
|
|
})
|
|
|
|
|
).toBeTruthy();
|
|
|
|
|
|
|
|
|
|
expect(await api.file.download('/repertory_test.dat', 'repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => { console.log(l, r, p, c); }))
|
|
|
|
|
.toBeTruthy();
|
|
|
|
|
expect(
|
|
|
|
|
await api.file.download(
|
|
|
|
|
'/repertory_test.dat',
|
|
|
|
|
'repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => {
|
|
|
|
|
console.log(l, r, p, c);
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
).toBeTruthy();
|
|
|
|
|
|
|
|
|
|
await expect(api.file.download('/repertory_test.dat', 'repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => { console.log(l, r, p, c); },
|
|
|
|
|
false))
|
|
|
|
|
.rejects.toThrow(Error);
|
|
|
|
|
await expect(
|
|
|
|
|
api.file.download(
|
|
|
|
|
'/repertory_test.dat',
|
|
|
|
|
'repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => {
|
|
|
|
|
console.log(l, r, p, c);
|
|
|
|
|
},
|
|
|
|
|
false
|
|
|
|
|
)
|
|
|
|
|
).rejects.toThrow(Error);
|
|
|
|
|
|
|
|
|
|
expect(await api.file.delete('/repertory_test.dat')).toEqual(0);
|
|
|
|
|
fs.unlinkSync('repertory_test.dat');
|
|
|
|
|
@@ -283,17 +367,29 @@ test('download fails if overwrite is false using api', async () => {
|
|
|
|
|
}, 60000);
|
|
|
|
|
|
|
|
|
|
test('can upload and overwrite a file using api', async () => {
|
|
|
|
|
const conn =
|
|
|
|
|
await repertory.create_pool(2, TEST_HOST, TEST_PORT, TEST_PASSWORD);
|
|
|
|
|
const conn = await repertory.create_pool(
|
|
|
|
|
2,
|
|
|
|
|
TEST_HOST,
|
|
|
|
|
TEST_PORT,
|
|
|
|
|
TEST_PASSWORD
|
|
|
|
|
);
|
|
|
|
|
const api = repertory.create_api(conn);
|
|
|
|
|
expect(await api.file.upload('test.dat', '/repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => { console.log(l, r, p, c); }))
|
|
|
|
|
.toBeTruthy();
|
|
|
|
|
expect(
|
|
|
|
|
await api.file.upload('test.dat', '/repertory_test.dat', (l, r, p, c) => {
|
|
|
|
|
console.log(l, r, p, c);
|
|
|
|
|
})
|
|
|
|
|
).toBeTruthy();
|
|
|
|
|
|
|
|
|
|
expect(await api.file.upload('test.dat', '/repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => { console.log(l, r, p, c); },
|
|
|
|
|
true))
|
|
|
|
|
.toBeTruthy();
|
|
|
|
|
expect(
|
|
|
|
|
await api.file.upload(
|
|
|
|
|
'test.dat',
|
|
|
|
|
'/repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => {
|
|
|
|
|
console.log(l, r, p, c);
|
|
|
|
|
},
|
|
|
|
|
true
|
|
|
|
|
)
|
|
|
|
|
).toBeTruthy();
|
|
|
|
|
|
|
|
|
|
expect(await api.file.delete('/repertory_test.dat')).toEqual(0);
|
|
|
|
|
|
|
|
|
|
@@ -301,17 +397,29 @@ test('can upload and overwrite a file using api', async () => {
|
|
|
|
|
}, 60000);
|
|
|
|
|
|
|
|
|
|
test('upload fails if overwrite is false using api', async () => {
|
|
|
|
|
const conn =
|
|
|
|
|
await repertory.create_pool(2, TEST_HOST, TEST_PORT, TEST_PASSWORD);
|
|
|
|
|
const conn = await repertory.create_pool(
|
|
|
|
|
2,
|
|
|
|
|
TEST_HOST,
|
|
|
|
|
TEST_PORT,
|
|
|
|
|
TEST_PASSWORD
|
|
|
|
|
);
|
|
|
|
|
const api = repertory.create_api(conn);
|
|
|
|
|
expect(await api.file.upload('test.dat', '/repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => { console.log(l, r, p, c); }))
|
|
|
|
|
.toBeTruthy();
|
|
|
|
|
expect(
|
|
|
|
|
await api.file.upload('test.dat', '/repertory_test.dat', (l, r, p, c) => {
|
|
|
|
|
console.log(l, r, p, c);
|
|
|
|
|
})
|
|
|
|
|
).toBeTruthy();
|
|
|
|
|
|
|
|
|
|
await expect(api.file.upload('test.dat', '/repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => { console.log(l, r, p, c); },
|
|
|
|
|
false))
|
|
|
|
|
.rejects.toThrow(Error);
|
|
|
|
|
await expect(
|
|
|
|
|
api.file.upload(
|
|
|
|
|
'test.dat',
|
|
|
|
|
'/repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => {
|
|
|
|
|
console.log(l, r, p, c);
|
|
|
|
|
},
|
|
|
|
|
false
|
|
|
|
|
)
|
|
|
|
|
).rejects.toThrow(Error);
|
|
|
|
|
|
|
|
|
|
expect(await api.file.delete('/repertory_test.dat')).toEqual(0);
|
|
|
|
|
|
|
|
|
|
@@ -319,12 +427,18 @@ test('upload fails if overwrite is false using api', async () => {
|
|
|
|
|
}, 60000);
|
|
|
|
|
|
|
|
|
|
test('can resume download using api', async () => {
|
|
|
|
|
const conn =
|
|
|
|
|
await repertory.create_pool(2, TEST_HOST, TEST_PORT, TEST_PASSWORD);
|
|
|
|
|
const conn = await repertory.create_pool(
|
|
|
|
|
2,
|
|
|
|
|
TEST_HOST,
|
|
|
|
|
TEST_PORT,
|
|
|
|
|
TEST_PASSWORD
|
|
|
|
|
);
|
|
|
|
|
const api = repertory.create_api(conn);
|
|
|
|
|
expect(await api.file.upload('test.dat', '/repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => { console.log(l, r, p, c); }))
|
|
|
|
|
.toBeTruthy();
|
|
|
|
|
expect(
|
|
|
|
|
await api.file.upload('test.dat', '/repertory_test.dat', (l, r, p, c) => {
|
|
|
|
|
console.log(l, r, p, c);
|
|
|
|
|
})
|
|
|
|
|
).toBeTruthy();
|
|
|
|
|
|
|
|
|
|
const fd = fs.openSync('test.dat', 'r');
|
|
|
|
|
const buffer = Buffer.alloc(1024);
|
|
|
|
|
@@ -333,13 +447,21 @@ test('can resume download using api', async () => {
|
|
|
|
|
|
|
|
|
|
fs.writeFileSync('repertory_test.dat', buffer);
|
|
|
|
|
|
|
|
|
|
expect(await api.file.download('/repertory_test.dat', 'repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => { console.log(l, r, p, c); },
|
|
|
|
|
false, true))
|
|
|
|
|
.toBeTruthy();
|
|
|
|
|
expect(
|
|
|
|
|
await api.file.download(
|
|
|
|
|
'/repertory_test.dat',
|
|
|
|
|
'repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => {
|
|
|
|
|
console.log(l, r, p, c);
|
|
|
|
|
},
|
|
|
|
|
false,
|
|
|
|
|
true
|
|
|
|
|
)
|
|
|
|
|
).toBeTruthy();
|
|
|
|
|
|
|
|
|
|
expect(await calculate_sha256('test.dat'))
|
|
|
|
|
.toEqual(await calculate_sha256('repertory_test.dat'));
|
|
|
|
|
expect(await calculate_sha256('test.dat')).toEqual(
|
|
|
|
|
await calculate_sha256('repertory_test.dat')
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(await api.file.delete('/repertory_test.dat')).toEqual(0);
|
|
|
|
|
fs.unlinkSync('repertory_test.dat');
|
|
|
|
|
@@ -348,8 +470,12 @@ test('can resume download using api', async () => {
|
|
|
|
|
}, 60000);
|
|
|
|
|
|
|
|
|
|
test('can resume upload using api', async () => {
|
|
|
|
|
const conn =
|
|
|
|
|
await repertory.create_pool(2, TEST_HOST, TEST_PORT, TEST_PASSWORD);
|
|
|
|
|
const conn = await repertory.create_pool(
|
|
|
|
|
2,
|
|
|
|
|
TEST_HOST,
|
|
|
|
|
TEST_PORT,
|
|
|
|
|
TEST_PASSWORD
|
|
|
|
|
);
|
|
|
|
|
const api = repertory.create_api(conn);
|
|
|
|
|
|
|
|
|
|
const fd = fs.openSync('test.dat', 'r');
|
|
|
|
|
@@ -361,17 +487,31 @@ test('can resume upload using api', async () => {
|
|
|
|
|
await f.write(0, buffer);
|
|
|
|
|
await f.close();
|
|
|
|
|
|
|
|
|
|
expect(await api.file.upload('test.dat', '/repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => { console.log(l, r, p, c); },
|
|
|
|
|
false, true))
|
|
|
|
|
.toBeTruthy();
|
|
|
|
|
expect(
|
|
|
|
|
await api.file.upload(
|
|
|
|
|
'test.dat',
|
|
|
|
|
'/repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => {
|
|
|
|
|
console.log(l, r, p, c);
|
|
|
|
|
},
|
|
|
|
|
false,
|
|
|
|
|
true
|
|
|
|
|
)
|
|
|
|
|
).toBeTruthy();
|
|
|
|
|
|
|
|
|
|
expect(await api.file.download('/repertory_test.dat', 'repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => { console.log(l, r, p, c); }))
|
|
|
|
|
.toBeTruthy();
|
|
|
|
|
expect(
|
|
|
|
|
await api.file.download(
|
|
|
|
|
'/repertory_test.dat',
|
|
|
|
|
'repertory_test.dat',
|
|
|
|
|
(l, r, p, c) => {
|
|
|
|
|
console.log(l, r, p, c);
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
).toBeTruthy();
|
|
|
|
|
|
|
|
|
|
expect(await calculate_sha256('test.dat'))
|
|
|
|
|
.toEqual(await calculate_sha256('repertory_test.dat'));
|
|
|
|
|
expect(await calculate_sha256('test.dat')).toEqual(
|
|
|
|
|
await calculate_sha256('repertory_test.dat')
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
expect(await api.file.delete('/repertory_test.dat')).toEqual(0);
|
|
|
|
|
fs.unlinkSync('repertory_test.dat');
|
|
|
|
|
|