-
Notifications
You must be signed in to change notification settings - Fork 252
Expand file tree
/
Copy pathrecompose.test.ts
More file actions
77 lines (63 loc) · 2.36 KB
/
Copy pathrecompose.test.ts
File metadata and controls
77 lines (63 loc) · 2.36 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test, vi } from 'vitest';
import { EnumStatusCode } from '@wundergraph/cosmo-connect/dist/common/common_pb';
import { joinLabel } from '@wundergraph/cosmo-shared';
import { ClickHouseClient } from '../../src/core/clickhouse/index.js';
import { afterAllSetup, beforeAllSetup, genID, genUniqueLabel } from '../../src/core/test-util.js';
import {
assertNumberOfCompositions,
createFederatedGraph,
createNamespace,
createThenPublishSubgraph,
SetupTest,
} from '../test-util.js';
vi.mock('../../src/core/clickhouse/index.js', () => {
const ClickHouseClient = vi.fn();
ClickHouseClient.prototype.queryPromise = vi.fn();
return { ClickHouseClient };
});
describe('federated-graph recompose tests', () => {
let chClient: ClickHouseClient;
let dbname = '';
beforeAll(async () => {
dbname = await beforeAllSetup();
});
beforeEach(() => {
chClient = new ClickHouseClient();
});
afterEach(() => {
vi.clearAllMocks();
});
afterAll(async () => {
await afterAllSetup(dbname);
});
test('that recomposing a published federated graph succeeds and triggers a new composition', async (testContext) => {
const { client, server } = await SetupTest({ dbname, chClient });
testContext.onTestFinished(() => server.close());
const namespace = genID('namespace').toLowerCase();
await createNamespace(client, namespace);
const subgraphName = genID('subgraph');
const fedGraphName = genID('fedGraph');
const label = genUniqueLabel('label');
const subgraphSchemaSDL = 'type Query { hello: String! }';
await createThenPublishSubgraph(
client,
subgraphName,
namespace,
subgraphSchemaSDL,
[label],
'http://localhost:8082',
);
await createFederatedGraph(client, fedGraphName, namespace, [joinLabel(label)], 'http://localhost:8080');
await assertNumberOfCompositions(client, fedGraphName, 1, namespace);
const response = await client.recomposeGraph({
name: fedGraphName,
namespace,
isMonograph: false,
});
expect(response.response).toBeDefined();
expect(response.response!.code).toBe(EnumStatusCode.OK);
expect(response.compositionErrors).toHaveLength(0);
expect(response.deploymentErrors).toHaveLength(0);
await assertNumberOfCompositions(client, fedGraphName, 2, namespace);
});
});