Added directory/file exists
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import {get_version, instance_id, package_json} from '../utils/constants';
|
||||
import { get_version, instance_id, package_json } from '../utils/constants';
|
||||
import * as uuid from 'uuid';
|
||||
|
||||
test(`can read 'package.json'`, () => {
|
||||
@@ -14,7 +14,7 @@ test(`'instance_id' is valid`, () => {
|
||||
|
||||
test(`'version' can be read from 'package.json'`, () => {
|
||||
console.log(get_version());
|
||||
expect(get_version()).toBe('1.3.1-r1');
|
||||
expect(get_version()).toBe('1.3.1-r3');
|
||||
});
|
||||
|
||||
test(`'version' can be overridden by environment variable`, () => {
|
||||
|
||||
@@ -102,6 +102,8 @@ test('can create and remove a directory using api', async () => {
|
||||
);
|
||||
const api = repertory.create_api(conn);
|
||||
expect(await api.directory.create('/repertory_js')).toEqual(0);
|
||||
expect(await api.directory.exists('/repertory_js')).toEqual(true);
|
||||
expect(await api.file.exists('/repertory_js')).toEqual(false);
|
||||
expect(await api.directory.remove('/repertory_js')).toEqual(0);
|
||||
|
||||
await conn.disconnect();
|
||||
@@ -278,6 +280,8 @@ test('can upload and download a file using api', async () => {
|
||||
await calculate_sha256('repertory_test.dat')
|
||||
);
|
||||
|
||||
expect(await api.directory.exists('/repertory_test.dat')).toEqual(false);
|
||||
expect(await api.file.exists('/repertory_test.dat')).toEqual(true);
|
||||
expect(await api.file.delete('/repertory_test.dat')).toEqual(0);
|
||||
fs.unlinkSync('repertory_test.dat');
|
||||
|
||||
@@ -518,3 +522,27 @@ test('can resume upload using api', async () => {
|
||||
|
||||
await conn.disconnect();
|
||||
}, 60000);
|
||||
|
||||
test('exists returns false if directory is not found', async () => {
|
||||
const conn = await repertory.create_pool(
|
||||
2,
|
||||
TEST_HOST,
|
||||
TEST_PORT,
|
||||
TEST_PASSWORD
|
||||
);
|
||||
const api = repertory.create_api(conn);
|
||||
expect(await api.directory.exists('/cow')).toEqual(false);
|
||||
await conn.disconnect();
|
||||
});
|
||||
|
||||
test('exists returns false if file is not found', async () => {
|
||||
const conn = await repertory.create_pool(
|
||||
2,
|
||||
TEST_HOST,
|
||||
TEST_PORT,
|
||||
TEST_PASSWORD
|
||||
);
|
||||
const api = repertory.create_api(conn);
|
||||
expect(await api.file.exists('/cow')).toEqual(false);
|
||||
await conn.disconnect();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user