@powersync/service-core-tests 0.15.0 → 0.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/dist/test-utils/general-utils.d.ts +13 -1
- package/dist/test-utils/general-utils.js +30 -1
- package/dist/test-utils/general-utils.js.map +1 -1
- package/dist/test-utils/stream_utils.js +2 -2
- package/dist/test-utils/stream_utils.js.map +1 -1
- package/dist/tests/register-compacting-tests.js +266 -257
- package/dist/tests/register-compacting-tests.js.map +1 -1
- package/dist/tests/register-data-storage-checkpoint-tests.js +36 -57
- package/dist/tests/register-data-storage-checkpoint-tests.js.map +1 -1
- package/dist/tests/register-data-storage-data-tests.js +839 -863
- package/dist/tests/register-data-storage-data-tests.js.map +1 -1
- package/dist/tests/register-data-storage-parameter-tests.js +228 -236
- package/dist/tests/register-data-storage-parameter-tests.js.map +1 -1
- package/dist/tests/register-parameter-compacting-tests.js +81 -89
- package/dist/tests/register-parameter-compacting-tests.js.map +1 -1
- package/dist/tests/register-sync-tests.js +468 -462
- package/dist/tests/register-sync-tests.js.map +1 -1
- package/package.json +3 -3
- package/src/test-utils/general-utils.ts +41 -2
- package/src/test-utils/stream_utils.ts +2 -2
- package/src/tests/register-compacting-tests.ts +279 -270
- package/src/tests/register-data-storage-checkpoint-tests.ts +36 -57
- package/src/tests/register-data-storage-data-tests.ts +673 -770
- package/src/tests/register-data-storage-parameter-tests.ts +245 -257
- package/src/tests/register-parameter-compacting-tests.ts +84 -92
- package/src/tests/register-sync-tests.ts +375 -391
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -18,7 +18,6 @@ import { parameterLookupScope } from './util.js';
|
|
|
18
18
|
export function registerDataStorageParameterTests(config: storage.TestStorageConfig) {
|
|
19
19
|
const generateStorageFactory = config.factory;
|
|
20
20
|
const storageVersion = config.storageVersion ?? CURRENT_STORAGE_VERSION;
|
|
21
|
-
const TEST_TABLE = test_utils.makeTestTable('test', ['id'], config);
|
|
22
21
|
const MYBUCKET_1 = parameterLookupScope('mybucket', '1');
|
|
23
22
|
|
|
24
23
|
test('save and load parameters', async () => {
|
|
@@ -39,36 +38,36 @@ bucket_definitions:
|
|
|
39
38
|
);
|
|
40
39
|
const bucketStorage = factory.getInstance(syncRules);
|
|
41
40
|
|
|
42
|
-
await bucketStorage.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
await batch.save({
|
|
58
|
-
sourceTable: TEST_TABLE,
|
|
59
|
-
tag: storage.SaveOperationTag.INSERT,
|
|
60
|
-
after: {
|
|
61
|
-
id: 't1',
|
|
62
|
-
id1: 'user1',
|
|
63
|
-
id2: 'user2',
|
|
64
|
-
group_id: 'group1a'
|
|
65
|
-
},
|
|
66
|
-
afterReplicaId: test_utils.rid('t1')
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
await batch.commit('1/1');
|
|
41
|
+
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
42
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
43
|
+
await writer.markAllSnapshotDone('1/1');
|
|
44
|
+
|
|
45
|
+
await writer.save({
|
|
46
|
+
sourceTable: testTable,
|
|
47
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
48
|
+
after: {
|
|
49
|
+
id: 't2',
|
|
50
|
+
id1: 'user3',
|
|
51
|
+
id2: 'user4',
|
|
52
|
+
group_id: 'group2a'
|
|
53
|
+
},
|
|
54
|
+
afterReplicaId: test_utils.rid('t2')
|
|
70
55
|
});
|
|
71
56
|
|
|
57
|
+
await writer.save({
|
|
58
|
+
sourceTable: testTable,
|
|
59
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
60
|
+
after: {
|
|
61
|
+
id: 't1',
|
|
62
|
+
id1: 'user1',
|
|
63
|
+
id2: 'user2',
|
|
64
|
+
group_id: 'group1a'
|
|
65
|
+
},
|
|
66
|
+
afterReplicaId: test_utils.rid('t1')
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
await writer.commit('1/1');
|
|
70
|
+
|
|
72
71
|
const checkpoint = await bucketStorage.getCheckpoint();
|
|
73
72
|
const parameters = await checkpoint.getParameterSets([ScopedParameterLookup.direct(MYBUCKET_1, ['user1'])]);
|
|
74
73
|
expect(parameters).toEqual([
|
|
@@ -96,32 +95,30 @@ bucket_definitions:
|
|
|
96
95
|
);
|
|
97
96
|
const bucketStorage = factory.getInstance(syncRules);
|
|
98
97
|
|
|
99
|
-
await bucketStorage.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
await batch.commit('1/1');
|
|
98
|
+
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
99
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
100
|
+
await writer.markAllSnapshotDone('1/1');
|
|
101
|
+
await writer.save({
|
|
102
|
+
sourceTable: testTable,
|
|
103
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
104
|
+
after: {
|
|
105
|
+
id: 'user1',
|
|
106
|
+
group_id: 'group1'
|
|
107
|
+
},
|
|
108
|
+
afterReplicaId: test_utils.rid('user1')
|
|
111
109
|
});
|
|
110
|
+
await writer.commit('1/1');
|
|
112
111
|
const checkpoint1 = await bucketStorage.getCheckpoint();
|
|
113
|
-
await
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
afterReplicaId: test_utils.rid('user1')
|
|
122
|
-
});
|
|
123
|
-
await batch.commit('1/2');
|
|
112
|
+
await writer.save({
|
|
113
|
+
sourceTable: testTable,
|
|
114
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
115
|
+
after: {
|
|
116
|
+
id: 'user1',
|
|
117
|
+
group_id: 'group2'
|
|
118
|
+
},
|
|
119
|
+
afterReplicaId: test_utils.rid('user1')
|
|
124
120
|
});
|
|
121
|
+
await writer.commit('1/2');
|
|
125
122
|
const checkpoint2 = await bucketStorage.getCheckpoint();
|
|
126
123
|
|
|
127
124
|
const parameters = await checkpoint2.getParameterSets([ScopedParameterLookup.direct(MYBUCKET_1, ['user1'])]);
|
|
@@ -158,48 +155,44 @@ bucket_definitions:
|
|
|
158
155
|
);
|
|
159
156
|
const bucketStorage = factory.getInstance(syncRules);
|
|
160
157
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
await
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
afterReplicaId: test_utils.rid('todo2')
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
await batch.commit('1/1');
|
|
158
|
+
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
159
|
+
const table = await test_utils.resolveTestTable(writer, 'todos', ['id', 'list_id'], config);
|
|
160
|
+
await writer.markAllSnapshotDone('1/1');
|
|
161
|
+
// Create two todos which initially belong to different lists
|
|
162
|
+
await writer.save({
|
|
163
|
+
sourceTable: table,
|
|
164
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
165
|
+
after: {
|
|
166
|
+
id: 'todo1',
|
|
167
|
+
list_id: 'list1'
|
|
168
|
+
},
|
|
169
|
+
afterReplicaId: test_utils.rid('todo1')
|
|
170
|
+
});
|
|
171
|
+
await writer.save({
|
|
172
|
+
sourceTable: table,
|
|
173
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
174
|
+
after: {
|
|
175
|
+
id: 'todo2',
|
|
176
|
+
list_id: 'list2'
|
|
177
|
+
},
|
|
178
|
+
afterReplicaId: test_utils.rid('todo2')
|
|
186
179
|
});
|
|
187
180
|
|
|
188
|
-
await
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
await batch.commit('1/1');
|
|
181
|
+
await writer.commit('1/1');
|
|
182
|
+
|
|
183
|
+
// Update the second todo item to now belong to list 1
|
|
184
|
+
await writer.save({
|
|
185
|
+
sourceTable: table,
|
|
186
|
+
tag: storage.SaveOperationTag.UPDATE,
|
|
187
|
+
after: {
|
|
188
|
+
id: 'todo2',
|
|
189
|
+
list_id: 'list1'
|
|
190
|
+
},
|
|
191
|
+
afterReplicaId: test_utils.rid('todo2')
|
|
201
192
|
});
|
|
202
193
|
|
|
194
|
+
await writer.commit('1/1');
|
|
195
|
+
|
|
203
196
|
// We specifically request the todo_ids for both lists.
|
|
204
197
|
// There removal operation for the association of `list2`::`todo2` should not interfere with the new
|
|
205
198
|
// association of `list1`::`todo2`
|
|
@@ -237,24 +230,24 @@ bucket_definitions:
|
|
|
237
230
|
);
|
|
238
231
|
const bucketStorage = factory.getInstance(syncRules);
|
|
239
232
|
|
|
240
|
-
await bucketStorage.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
await batch.commit('1/1');
|
|
233
|
+
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
234
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
235
|
+
await writer.markAllSnapshotDone('1/1');
|
|
236
|
+
await writer.save({
|
|
237
|
+
sourceTable: testTable,
|
|
238
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
239
|
+
after: {
|
|
240
|
+
id: 't1',
|
|
241
|
+
group_id: 'group1',
|
|
242
|
+
n1: 314n,
|
|
243
|
+
f2: 314,
|
|
244
|
+
f3: 3.14
|
|
245
|
+
},
|
|
246
|
+
afterReplicaId: test_utils.rid('t1')
|
|
256
247
|
});
|
|
257
248
|
|
|
249
|
+
await writer.commit('1/1');
|
|
250
|
+
|
|
258
251
|
const TEST_PARAMS = { group_id: 'group1' };
|
|
259
252
|
|
|
260
253
|
const checkpoint = await bucketStorage.getCheckpoint();
|
|
@@ -293,35 +286,35 @@ bucket_definitions:
|
|
|
293
286
|
);
|
|
294
287
|
const bucketStorage = factory.getInstance(syncRules);
|
|
295
288
|
|
|
296
|
-
await bucketStorage.
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
await batch.commit('1/1');
|
|
289
|
+
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
290
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
291
|
+
await writer.markAllSnapshotDone('1/1');
|
|
292
|
+
await writer.save({
|
|
293
|
+
sourceTable: testTable,
|
|
294
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
295
|
+
after: {
|
|
296
|
+
id: 't1',
|
|
297
|
+
group_id: 'group1',
|
|
298
|
+
n1: 1152921504606846976n // 2^60
|
|
299
|
+
},
|
|
300
|
+
afterReplicaId: test_utils.rid('t1')
|
|
301
|
+
});
|
|
302
|
+
|
|
303
|
+
await writer.save({
|
|
304
|
+
sourceTable: testTable,
|
|
305
|
+
tag: storage.SaveOperationTag.UPDATE,
|
|
306
|
+
after: {
|
|
307
|
+
id: 't1',
|
|
308
|
+
group_id: 'group1',
|
|
309
|
+
// Simulate a TOAST value, even though it can't happen for values like this
|
|
310
|
+
// in practice.
|
|
311
|
+
n1: undefined
|
|
312
|
+
},
|
|
313
|
+
afterReplicaId: test_utils.rid('t1')
|
|
323
314
|
});
|
|
324
315
|
|
|
316
|
+
await writer.commit('1/1');
|
|
317
|
+
|
|
325
318
|
const TEST_PARAMS = { group_id: 'group1' };
|
|
326
319
|
|
|
327
320
|
const checkpoint = await bucketStorage.getCheckpoint();
|
|
@@ -333,8 +326,6 @@ bucket_definitions:
|
|
|
333
326
|
});
|
|
334
327
|
|
|
335
328
|
test('save and load parameters with workspaceId', async () => {
|
|
336
|
-
const WORKSPACE_TABLE = test_utils.makeTestTable('workspace', ['id'], config);
|
|
337
|
-
|
|
338
329
|
await using factory = await generateStorageFactory();
|
|
339
330
|
const syncRules = await factory.updateSyncRules(
|
|
340
331
|
updateSyncRulesFromYaml(
|
|
@@ -354,19 +345,19 @@ bucket_definitions:
|
|
|
354
345
|
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncRules();
|
|
355
346
|
const bucketStorage = factory.getInstance(syncRules);
|
|
356
347
|
|
|
357
|
-
await bucketStorage.
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
await batch.commit('1/1');
|
|
348
|
+
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
349
|
+
const workspaceTable = await test_utils.resolveTestTable(writer, 'workspace', ['id'], config);
|
|
350
|
+
await writer.markAllSnapshotDone('1/1');
|
|
351
|
+
await writer.save({
|
|
352
|
+
sourceTable: workspaceTable,
|
|
353
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
354
|
+
after: {
|
|
355
|
+
id: 'workspace1',
|
|
356
|
+
userId: 'u1'
|
|
357
|
+
},
|
|
358
|
+
afterReplicaId: test_utils.rid('workspace1')
|
|
369
359
|
});
|
|
360
|
+
await writer.commit('1/1');
|
|
370
361
|
const checkpoint = await bucketStorage.getCheckpoint();
|
|
371
362
|
|
|
372
363
|
const parameters = new RequestParameters(new JwtPayload({ sub: 'u1' }), {});
|
|
@@ -393,8 +384,6 @@ bucket_definitions:
|
|
|
393
384
|
});
|
|
394
385
|
|
|
395
386
|
test('save and load parameters with dynamic global buckets', async () => {
|
|
396
|
-
const WORKSPACE_TABLE = test_utils.makeTestTable('workspace', undefined, config);
|
|
397
|
-
|
|
398
387
|
await using factory = await generateStorageFactory();
|
|
399
388
|
const syncRules = await factory.updateSyncRules(
|
|
400
389
|
updateSyncRulesFromYaml(
|
|
@@ -414,41 +403,41 @@ bucket_definitions:
|
|
|
414
403
|
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncRules();
|
|
415
404
|
const bucketStorage = factory.getInstance(syncRules);
|
|
416
405
|
|
|
417
|
-
await bucketStorage.
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
await batch.save({
|
|
430
|
-
sourceTable: WORKSPACE_TABLE,
|
|
431
|
-
tag: storage.SaveOperationTag.INSERT,
|
|
432
|
-
after: {
|
|
433
|
-
id: 'workspace2',
|
|
434
|
-
visibility: 'private'
|
|
435
|
-
},
|
|
436
|
-
afterReplicaId: test_utils.rid('workspace2')
|
|
437
|
-
});
|
|
438
|
-
|
|
439
|
-
await batch.save({
|
|
440
|
-
sourceTable: WORKSPACE_TABLE,
|
|
441
|
-
tag: storage.SaveOperationTag.INSERT,
|
|
442
|
-
after: {
|
|
443
|
-
id: 'workspace3',
|
|
444
|
-
visibility: 'public'
|
|
445
|
-
},
|
|
446
|
-
afterReplicaId: test_utils.rid('workspace3')
|
|
447
|
-
});
|
|
448
|
-
|
|
449
|
-
await batch.commit('1/1');
|
|
406
|
+
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
407
|
+
const workspaceTable = await test_utils.resolveTestTable(writer, 'workspace', undefined, config);
|
|
408
|
+
await writer.markAllSnapshotDone('1/1');
|
|
409
|
+
await writer.save({
|
|
410
|
+
sourceTable: workspaceTable,
|
|
411
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
412
|
+
after: {
|
|
413
|
+
id: 'workspace1',
|
|
414
|
+
visibility: 'public'
|
|
415
|
+
},
|
|
416
|
+
afterReplicaId: test_utils.rid('workspace1')
|
|
450
417
|
});
|
|
451
418
|
|
|
419
|
+
await writer.save({
|
|
420
|
+
sourceTable: workspaceTable,
|
|
421
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
422
|
+
after: {
|
|
423
|
+
id: 'workspace2',
|
|
424
|
+
visibility: 'private'
|
|
425
|
+
},
|
|
426
|
+
afterReplicaId: test_utils.rid('workspace2')
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
await writer.save({
|
|
430
|
+
sourceTable: workspaceTable,
|
|
431
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
432
|
+
after: {
|
|
433
|
+
id: 'workspace3',
|
|
434
|
+
visibility: 'public'
|
|
435
|
+
},
|
|
436
|
+
afterReplicaId: test_utils.rid('workspace3')
|
|
437
|
+
});
|
|
438
|
+
|
|
439
|
+
await writer.commit('1/1');
|
|
440
|
+
|
|
452
441
|
const checkpoint = await bucketStorage.getCheckpoint();
|
|
453
442
|
|
|
454
443
|
const parameters = new RequestParameters(new JwtPayload({ sub: 'unknown' }), {});
|
|
@@ -483,8 +472,6 @@ bucket_definitions:
|
|
|
483
472
|
});
|
|
484
473
|
|
|
485
474
|
test('multiple parameter queries', async () => {
|
|
486
|
-
const WORKSPACE_TABLE = test_utils.makeTestTable('workspace', undefined, config);
|
|
487
|
-
|
|
488
475
|
await using factory = await generateStorageFactory();
|
|
489
476
|
const syncRules = await factory.updateSyncRules(
|
|
490
477
|
updateSyncRulesFromYaml(
|
|
@@ -506,53 +493,53 @@ bucket_definitions:
|
|
|
506
493
|
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncRules();
|
|
507
494
|
const bucketStorage = factory.getInstance(syncRules);
|
|
508
495
|
|
|
509
|
-
await bucketStorage.
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
await batch.save({
|
|
522
|
-
sourceTable: WORKSPACE_TABLE,
|
|
523
|
-
tag: storage.SaveOperationTag.INSERT,
|
|
524
|
-
after: {
|
|
525
|
-
id: 'workspace2',
|
|
526
|
-
visibility: 'private'
|
|
527
|
-
},
|
|
528
|
-
afterReplicaId: test_utils.rid('workspace2')
|
|
529
|
-
});
|
|
530
|
-
|
|
531
|
-
await batch.save({
|
|
532
|
-
sourceTable: WORKSPACE_TABLE,
|
|
533
|
-
tag: storage.SaveOperationTag.INSERT,
|
|
534
|
-
after: {
|
|
535
|
-
id: 'workspace3',
|
|
536
|
-
user_id: 'u1',
|
|
537
|
-
visibility: 'private'
|
|
538
|
-
},
|
|
539
|
-
afterReplicaId: test_utils.rid('workspace3')
|
|
540
|
-
});
|
|
541
|
-
|
|
542
|
-
await batch.save({
|
|
543
|
-
sourceTable: WORKSPACE_TABLE,
|
|
544
|
-
tag: storage.SaveOperationTag.INSERT,
|
|
545
|
-
after: {
|
|
546
|
-
id: 'workspace4',
|
|
547
|
-
user_id: 'u2',
|
|
548
|
-
visibility: 'private'
|
|
549
|
-
},
|
|
550
|
-
afterReplicaId: test_utils.rid('workspace4')
|
|
551
|
-
});
|
|
552
|
-
|
|
553
|
-
await batch.commit('1/1');
|
|
496
|
+
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
497
|
+
const workspaceTable = await test_utils.resolveTestTable(writer, 'workspace', undefined, config);
|
|
498
|
+
await writer.markAllSnapshotDone('1/1');
|
|
499
|
+
await writer.save({
|
|
500
|
+
sourceTable: workspaceTable,
|
|
501
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
502
|
+
after: {
|
|
503
|
+
id: 'workspace1',
|
|
504
|
+
visibility: 'public'
|
|
505
|
+
},
|
|
506
|
+
afterReplicaId: test_utils.rid('workspace1')
|
|
554
507
|
});
|
|
555
508
|
|
|
509
|
+
await writer.save({
|
|
510
|
+
sourceTable: workspaceTable,
|
|
511
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
512
|
+
after: {
|
|
513
|
+
id: 'workspace2',
|
|
514
|
+
visibility: 'private'
|
|
515
|
+
},
|
|
516
|
+
afterReplicaId: test_utils.rid('workspace2')
|
|
517
|
+
});
|
|
518
|
+
|
|
519
|
+
await writer.save({
|
|
520
|
+
sourceTable: workspaceTable,
|
|
521
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
522
|
+
after: {
|
|
523
|
+
id: 'workspace3',
|
|
524
|
+
user_id: 'u1',
|
|
525
|
+
visibility: 'private'
|
|
526
|
+
},
|
|
527
|
+
afterReplicaId: test_utils.rid('workspace3')
|
|
528
|
+
});
|
|
529
|
+
|
|
530
|
+
await writer.save({
|
|
531
|
+
sourceTable: workspaceTable,
|
|
532
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
533
|
+
after: {
|
|
534
|
+
id: 'workspace4',
|
|
535
|
+
user_id: 'u2',
|
|
536
|
+
visibility: 'private'
|
|
537
|
+
},
|
|
538
|
+
afterReplicaId: test_utils.rid('workspace4')
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
await writer.commit('1/1');
|
|
542
|
+
|
|
556
543
|
const checkpoint = await bucketStorage.getCheckpoint();
|
|
557
544
|
|
|
558
545
|
const parameters = new RequestParameters(new JwtPayload({ sub: 'u1' }), {});
|
|
@@ -605,23 +592,24 @@ bucket_definitions:
|
|
|
605
592
|
);
|
|
606
593
|
const bucketStorage = factory.getInstance(syncRules);
|
|
607
594
|
|
|
608
|
-
await bucketStorage.
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
await batch.truncate([TEST_TABLE]);
|
|
595
|
+
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
596
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
597
|
+
await writer.markAllSnapshotDone('1/1');
|
|
598
|
+
await writer.save({
|
|
599
|
+
sourceTable: testTable,
|
|
600
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
601
|
+
after: {
|
|
602
|
+
id: 't2',
|
|
603
|
+
id1: 'user3',
|
|
604
|
+
id2: 'user4',
|
|
605
|
+
group_id: 'group2a'
|
|
606
|
+
},
|
|
607
|
+
afterReplicaId: test_utils.rid('t2')
|
|
623
608
|
});
|
|
624
609
|
|
|
610
|
+
await writer.truncate([testTable]);
|
|
611
|
+
await writer.flush();
|
|
612
|
+
|
|
625
613
|
const checkpoint = await bucketStorage.getCheckpoint();
|
|
626
614
|
|
|
627
615
|
const parameters = await checkpoint.getParameterSets([ScopedParameterLookup.direct(MYBUCKET_1, ['user1'])]);
|
|
@@ -684,21 +672,21 @@ streams:
|
|
|
684
672
|
);
|
|
685
673
|
const bucketStorage = factory.getInstance(syncRules);
|
|
686
674
|
|
|
687
|
-
await bucketStorage.
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
await batch.commit('1/1');
|
|
675
|
+
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
676
|
+
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
677
|
+
await writer.markAllSnapshotDone('1/1');
|
|
678
|
+
await writer.save({
|
|
679
|
+
sourceTable: testTable,
|
|
680
|
+
tag: storage.SaveOperationTag.INSERT,
|
|
681
|
+
after: {
|
|
682
|
+
baz: 'baz',
|
|
683
|
+
bar: 'bar'
|
|
684
|
+
},
|
|
685
|
+
afterReplicaId: test_utils.rid('t1')
|
|
700
686
|
});
|
|
701
687
|
|
|
688
|
+
await writer.commit('1/1');
|
|
689
|
+
|
|
702
690
|
const checkpoint = await bucketStorage.getCheckpoint();
|
|
703
691
|
const parameters = await checkpoint.getParameterSets([
|
|
704
692
|
ScopedParameterLookup.direct(parameterLookupScope('lookup', '0'), ['baz'])
|