-
Notifications
You must be signed in to change notification settings - Fork 47
Expand file tree
/
Copy pathvalidation.test.ts
More file actions
62 lines (56 loc) · 1.87 KB
/
validation.test.ts
File metadata and controls
62 lines (56 loc) · 1.87 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
import { getDebugTablesInfo } from '@module/replication/replication-utils.js';
import { expect, test } from 'vitest';
import { INITIALIZED_MONGO_STORAGE_FACTORY } from './util.js';
import { WalStreamTestContext } from './wal_stream_utils.js';
test('validate tables', async () => {
await using context = await WalStreamTestContext.open(INITIALIZED_MONGO_STORAGE_FACTORY);
const { pool } = context;
await pool.query(`CREATE TABLE test_data(id uuid primary key default uuid_generate_v4(), description text)`);
const syncRuleContent = `
bucket_definitions:
global:
data:
- SELECT id, description FROM "test_data"
- SELECT * FROM "other"
- SELECT * FROM "other%"
`;
const syncRules = await context.factory.updateSyncRules({ content: syncRuleContent });
const tablePatterns = syncRules.parsed({ defaultSchema: 'public' }).sync_rules.config.getSourceTables();
const tableInfo = await getDebugTablesInfo({
db: pool,
publicationName: context.publicationName,
connectionTag: context.connectionTag,
tablePatterns: tablePatterns,
syncRules: syncRules.parsed({ defaultSchema: 'public' }).sync_rules.config
});
expect(tableInfo).toEqual([
{
schema: 'public',
pattern: 'test_data',
wildcard: false,
table: {
schema: 'public',
name: 'test_data',
replication_id: ['id'],
pattern: undefined,
data_queries: true,
parameter_queries: false,
errors: []
}
},
{
schema: 'public',
pattern: 'other',
wildcard: false,
table: {
schema: 'public',
name: 'other',
replication_id: [],
data_queries: true,
parameter_queries: false,
errors: [{ level: 'warning', message: 'Table "public"."other" not found.' }]
}
},
{ schema: 'public', pattern: 'other%', wildcard: true, tables: [] }
]);
});