feat: test case for parallel load & destroy instance
This commit is contained in:
@@ -13,12 +13,23 @@ test('init data center', async () => {
|
|||||||
expect(workspace).toBeTruthy();
|
expect(workspace).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('init data center singleton', async () => {
|
||||||
|
const [dc1, dc2] = await Promise.all([getDataCenter(), getDataCenter()]);
|
||||||
|
expect(dc1).toEqual(dc2);
|
||||||
|
|
||||||
|
const [ws1, ws2] = await Promise.all([
|
||||||
|
dc1.getWorkspace('test1'),
|
||||||
|
dc2.getWorkspace('test1'),
|
||||||
|
]);
|
||||||
|
expect(ws1).toEqual(ws2);
|
||||||
|
});
|
||||||
|
|
||||||
test('should init error with unknown provider', async () => {
|
test('should init error with unknown provider', async () => {
|
||||||
const dataCenter = await getDataCenter();
|
const dataCenter = await getDataCenter();
|
||||||
await dataCenter.clearWorkspaces();
|
await dataCenter.clearWorkspaces();
|
||||||
|
|
||||||
test.fail();
|
test.fail();
|
||||||
await dataCenter.getWorkspace('test2', 'not exist provider');
|
await dataCenter.getWorkspace('test2', { providerId: 'not exist provider' });
|
||||||
});
|
});
|
||||||
|
|
||||||
test.skip('init affine provider', async () => {
|
test.skip('init affine provider', async () => {
|
||||||
@@ -26,10 +37,10 @@ test.skip('init affine provider', async () => {
|
|||||||
await dataCenter.clearWorkspaces();
|
await dataCenter.clearWorkspaces();
|
||||||
|
|
||||||
// TODO: set constant token for testing
|
// TODO: set constant token for testing
|
||||||
await dataCenter.setWorkspaceConfig('6', 'token', 'YOUR_TOKEN');
|
const workspace = await dataCenter.getWorkspace('6', {
|
||||||
|
providerId: 'affine',
|
||||||
const workspace = await dataCenter.getWorkspace('6', 'affine');
|
config: { token: 'YOUR_TOKEN' },
|
||||||
|
});
|
||||||
expect(workspace).toBeTruthy();
|
expect(workspace).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -52,16 +63,27 @@ test('list workspaces', async () => {
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('destroy workspaces', async () => {
|
||||||
|
const dataCenter = await getDataCenter();
|
||||||
|
await dataCenter.clearWorkspaces();
|
||||||
|
|
||||||
|
const dc1 = await dataCenter.getWorkspace('test7');
|
||||||
|
await dataCenter.destroyWorkspace('test7');
|
||||||
|
const dc2 = await dataCenter.getWorkspace('test7');
|
||||||
|
|
||||||
|
expect(dc1 !== dc2).toBeTruthy();
|
||||||
|
});
|
||||||
|
|
||||||
test('remove workspaces', async () => {
|
test('remove workspaces', async () => {
|
||||||
const dataCenter = await getDataCenter();
|
const dataCenter = await getDataCenter();
|
||||||
await dataCenter.clearWorkspaces();
|
await dataCenter.clearWorkspaces();
|
||||||
|
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
dataCenter.getWorkspace('test7'),
|
|
||||||
dataCenter.getWorkspace('test8'),
|
dataCenter.getWorkspace('test8'),
|
||||||
|
dataCenter.getWorkspace('test9'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await dataCenter.removeWorkspace('test7');
|
await dataCenter.removeWorkspace('test8');
|
||||||
|
|
||||||
expect(await dataCenter.listWorkspace()).toStrictEqual(['test8']);
|
expect(await dataCenter.listWorkspace()).toStrictEqual(['test9']);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user