@powersync/service-core-tests 0.0.0-dev-20260909133214 → 0.0.0-dev-20260929095716
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 +23 -5
- package/dist/test-utils/AbstractStreamTestContext.js +4 -3
- package/dist/test-utils/AbstractStreamTestContext.js.map +1 -1
- package/dist/test-utils/leased-storage.d.ts +9 -0
- package/dist/test-utils/leased-storage.js +53 -0
- package/dist/test-utils/leased-storage.js.map +1 -0
- package/dist/test-utils/test-utils-index.d.ts +1 -0
- package/dist/test-utils/test-utils-index.js +1 -0
- package/dist/test-utils/test-utils-index.js.map +1 -1
- package/dist/tests/register-compacting-tests.js +8 -7
- package/dist/tests/register-compacting-tests.js.map +1 -1
- package/dist/tests/register-data-storage-checkpoint-tests.js +8 -7
- package/dist/tests/register-data-storage-checkpoint-tests.js.map +1 -1
- package/dist/tests/register-data-storage-data-tests.js +34 -22
- package/dist/tests/register-data-storage-data-tests.js.map +1 -1
- package/dist/tests/register-data-storage-parameter-tests.js +16 -15
- package/dist/tests/register-data-storage-parameter-tests.js.map +1 -1
- package/dist/tests/register-parameter-compacting-tests.js +3 -2
- package/dist/tests/register-parameter-compacting-tests.js.map +1 -1
- package/dist/tests/register-sync-tests.js +20 -19
- package/dist/tests/register-sync-tests.js.map +1 -1
- package/package.json +4 -4
- package/src/test-utils/AbstractStreamTestContext.ts +4 -3
- package/src/test-utils/leased-storage.ts +58 -0
- package/src/test-utils/test-utils-index.ts +1 -0
- package/src/tests/register-compacting-tests.ts +8 -7
- package/src/tests/register-data-storage-checkpoint-tests.ts +8 -7
- package/src/tests/register-data-storage-data-tests.ts +38 -22
- package/src/tests/register-data-storage-parameter-tests.ts +16 -15
- package/src/tests/register-parameter-compacting-tests.ts +3 -2
- package/src/tests/register-sync-tests.ts +20 -19
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
updateSyncRulesFromYaml
|
|
9
9
|
} from '@powersync/service-core';
|
|
10
10
|
import { describe, expect, test } from 'vitest';
|
|
11
|
+
import { getTestStorage } from '../test-utils/leased-storage.js';
|
|
11
12
|
import * as test_utils from '../test-utils/test-utils-index.js';
|
|
12
13
|
import { bucketRequest } from '../test-utils/test-utils-index.js';
|
|
13
14
|
|
|
@@ -36,6 +37,21 @@ export function registerDataStorageDataTests(config: storage.TestStorageConfig)
|
|
|
36
37
|
const generateStorageFactory = config.factory;
|
|
37
38
|
const storageVersion = config.storageVersion ?? storage.CURRENT_STORAGE_VERSION;
|
|
38
39
|
|
|
40
|
+
test('releases test replication leases when leaving an await using scope', async () => {
|
|
41
|
+
{
|
|
42
|
+
await using factory = await generateStorageFactory();
|
|
43
|
+
const stream = await factory.updateSyncRules(
|
|
44
|
+
updateSyncRulesFromYaml('bucket_definitions: {}', { storageVersion })
|
|
45
|
+
);
|
|
46
|
+
await getTestStorage(factory, stream);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
await using replacement = await generateStorageFactory({ doNotClear: true });
|
|
50
|
+
const deploying = await replacement.getDeployingSyncConfig();
|
|
51
|
+
expect(deploying).not.toBeNull();
|
|
52
|
+
await getTestStorage(replacement, deploying!.replicationStream);
|
|
53
|
+
});
|
|
54
|
+
|
|
39
55
|
test('removing row', async () => {
|
|
40
56
|
await using factory = await generateStorageFactory();
|
|
41
57
|
const { stream: replicationStream, content: syncRules } = await test_utils.deploySyncRules(
|
|
@@ -50,7 +66,7 @@ bucket_definitions:
|
|
|
50
66
|
{ storageVersion }
|
|
51
67
|
)
|
|
52
68
|
);
|
|
53
|
-
const bucketStorage = factory
|
|
69
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
54
70
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
55
71
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
56
72
|
|
|
@@ -116,7 +132,7 @@ bucket_definitions:
|
|
|
116
132
|
{ storageVersion }
|
|
117
133
|
)
|
|
118
134
|
);
|
|
119
|
-
const bucketStorage = factory
|
|
135
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
120
136
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
121
137
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
122
138
|
await writer.markAllSnapshotDone('1/1');
|
|
@@ -181,7 +197,7 @@ bucket_definitions:
|
|
|
181
197
|
{ storageVersion }
|
|
182
198
|
)
|
|
183
199
|
);
|
|
184
|
-
const bucketStorage = factory
|
|
200
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
185
201
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
186
202
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
187
203
|
await writer.markAllSnapshotDone('1/1');
|
|
@@ -251,7 +267,7 @@ bucket_definitions:
|
|
|
251
267
|
}
|
|
252
268
|
)
|
|
253
269
|
);
|
|
254
|
-
const bucketStorage = factory
|
|
270
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
255
271
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
256
272
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
257
273
|
await writer.markAllSnapshotDone('1/1');
|
|
@@ -314,7 +330,7 @@ bucket_definitions:
|
|
|
314
330
|
}
|
|
315
331
|
)
|
|
316
332
|
);
|
|
317
|
-
const bucketStorage = factory
|
|
333
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
318
334
|
{
|
|
319
335
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
320
336
|
const sourceTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
@@ -393,7 +409,7 @@ bucket_definitions:
|
|
|
393
409
|
}
|
|
394
410
|
)
|
|
395
411
|
);
|
|
396
|
-
const bucketStorage = factory
|
|
412
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
397
413
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
398
414
|
const sourceTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
399
415
|
await writer.markAllSnapshotDone('1/1');
|
|
@@ -465,7 +481,7 @@ bucket_definitions:
|
|
|
465
481
|
}
|
|
466
482
|
)
|
|
467
483
|
);
|
|
468
|
-
const bucketStorage = factory
|
|
484
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
469
485
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
470
486
|
const sourceTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
471
487
|
await writer.markAllSnapshotDone('1/1');
|
|
@@ -540,7 +556,7 @@ bucket_definitions:
|
|
|
540
556
|
{ storageVersion }
|
|
541
557
|
)
|
|
542
558
|
);
|
|
543
|
-
const bucketStorage = factory
|
|
559
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
544
560
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
545
561
|
const sourceTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
546
562
|
await writer.markAllSnapshotDone('1/1');
|
|
@@ -671,7 +687,7 @@ bucket_definitions:
|
|
|
671
687
|
{ storageVersion }
|
|
672
688
|
)
|
|
673
689
|
);
|
|
674
|
-
const bucketStorage = factory
|
|
690
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
675
691
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
676
692
|
const sourceTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
677
693
|
|
|
@@ -835,7 +851,7 @@ bucket_definitions:
|
|
|
835
851
|
}
|
|
836
852
|
)
|
|
837
853
|
);
|
|
838
|
-
const bucketStorage = factory
|
|
854
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
839
855
|
|
|
840
856
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
841
857
|
const sourceTable = await test_utils.resolveTestTable(writer, 'test', ['id', 'description'], config);
|
|
@@ -949,7 +965,7 @@ bucket_definitions:
|
|
|
949
965
|
}
|
|
950
966
|
)
|
|
951
967
|
);
|
|
952
|
-
const bucketStorage = factory
|
|
968
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
953
969
|
|
|
954
970
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
955
971
|
const sourceTable = await test_utils.resolveTestTable(writer, 'test', ['id', 'description'], config);
|
|
@@ -1053,7 +1069,7 @@ bucket_definitions:
|
|
|
1053
1069
|
}
|
|
1054
1070
|
)
|
|
1055
1071
|
);
|
|
1056
|
-
const bucketStorage = factory
|
|
1072
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
1057
1073
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1058
1074
|
const sourceTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
1059
1075
|
await writer.markAllSnapshotDone('1/1');
|
|
@@ -1167,7 +1183,7 @@ bucket_definitions:
|
|
|
1167
1183
|
}
|
|
1168
1184
|
)
|
|
1169
1185
|
);
|
|
1170
|
-
const bucketStorage = factory
|
|
1186
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
1171
1187
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1172
1188
|
const sourceTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
1173
1189
|
await writer.markAllSnapshotDone('1/1');
|
|
@@ -1267,7 +1283,7 @@ bucket_definitions:
|
|
|
1267
1283
|
{ storageVersion }
|
|
1268
1284
|
)
|
|
1269
1285
|
);
|
|
1270
|
-
const bucketStorage = factory
|
|
1286
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
1271
1287
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1272
1288
|
const sourceTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
1273
1289
|
await writer.markAllSnapshotDone('1/1');
|
|
@@ -1466,7 +1482,7 @@ bucket_definitions:
|
|
|
1466
1482
|
});
|
|
1467
1483
|
|
|
1468
1484
|
const r = await f.configureSyncRules(updateSyncRulesFromYaml('bucket_definitions: {}'));
|
|
1469
|
-
const storage = f
|
|
1485
|
+
const storage = await getTestStorage(f, r.persisted_sync_rules!);
|
|
1470
1486
|
await using writer = await storage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1471
1487
|
await writer.markAllSnapshotDone('1/0');
|
|
1472
1488
|
await writer.keepalive('1/0');
|
|
@@ -1495,7 +1511,7 @@ bucket_definitions:
|
|
|
1495
1511
|
}
|
|
1496
1512
|
)
|
|
1497
1513
|
);
|
|
1498
|
-
const bucketStorage = factory
|
|
1514
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
1499
1515
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1500
1516
|
|
|
1501
1517
|
const sourceTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config, 1);
|
|
@@ -1547,7 +1563,7 @@ bucket_definitions:
|
|
|
1547
1563
|
}
|
|
1548
1564
|
)
|
|
1549
1565
|
);
|
|
1550
|
-
const bucketStorage = factory
|
|
1566
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
1551
1567
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1552
1568
|
|
|
1553
1569
|
const sourceTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
@@ -1589,7 +1605,7 @@ bucket_definitions:
|
|
|
1589
1605
|
{ storageVersion }
|
|
1590
1606
|
)
|
|
1591
1607
|
);
|
|
1592
|
-
const bucketStorage = factory
|
|
1608
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
1593
1609
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1594
1610
|
await writer.markAllSnapshotDone('1/1');
|
|
1595
1611
|
await writer.commit('1/1');
|
|
@@ -1628,7 +1644,7 @@ bucket_definitions:
|
|
|
1628
1644
|
}
|
|
1629
1645
|
)
|
|
1630
1646
|
);
|
|
1631
|
-
const bucketStorage = factory
|
|
1647
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
1632
1648
|
await using writer1 = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1633
1649
|
await using writer2 = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1634
1650
|
const sourceTable = await test_utils.resolveTestTable(writer2, 'test', ['id'], config);
|
|
@@ -1679,7 +1695,7 @@ bucket_definitions:
|
|
|
1679
1695
|
}
|
|
1680
1696
|
)
|
|
1681
1697
|
);
|
|
1682
|
-
const bucketStorage = factory
|
|
1698
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
1683
1699
|
|
|
1684
1700
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1685
1701
|
const result1 = await writer.commit('1/1', { createEmptyCheckpoints: false });
|
|
@@ -1732,7 +1748,7 @@ bucket_definitions:
|
|
|
1732
1748
|
}
|
|
1733
1749
|
)
|
|
1734
1750
|
);
|
|
1735
|
-
const bucketStorage = factory
|
|
1751
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
1736
1752
|
await using snapshotWriter = await bucketStorage.createWriter({
|
|
1737
1753
|
...test_utils.BATCH_OPTIONS,
|
|
1738
1754
|
skipExistingRows: true
|
|
@@ -1803,7 +1819,7 @@ bucket_definitions:
|
|
|
1803
1819
|
}
|
|
1804
1820
|
)
|
|
1805
1821
|
);
|
|
1806
|
-
const bucketStorage = factory
|
|
1822
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
1807
1823
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1808
1824
|
const sourceTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
1809
1825
|
await writer.markAllSnapshotDone('1/1');
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
UnscopedParameterLookup
|
|
8
8
|
} from '@powersync/service-sync-rules';
|
|
9
9
|
import { expect, test } from 'vitest';
|
|
10
|
+
import { getTestStorage } from '../test-utils/leased-storage.js';
|
|
10
11
|
import * as test_utils from '../test-utils/test-utils-index.js';
|
|
11
12
|
import { bucketRequest } from '../test-utils/test-utils-index.js';
|
|
12
13
|
|
|
@@ -41,7 +42,7 @@ bucket_definitions:
|
|
|
41
42
|
}
|
|
42
43
|
)
|
|
43
44
|
);
|
|
44
|
-
const bucketStorage = factory
|
|
45
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
45
46
|
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
46
47
|
|
|
47
48
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
@@ -108,7 +109,7 @@ bucket_definitions:
|
|
|
108
109
|
}
|
|
109
110
|
)
|
|
110
111
|
);
|
|
111
|
-
const bucketStorage = factory
|
|
112
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
112
113
|
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
113
114
|
|
|
114
115
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
@@ -180,7 +181,7 @@ bucket_definitions:
|
|
|
180
181
|
{ storageVersion }
|
|
181
182
|
)
|
|
182
183
|
);
|
|
183
|
-
const bucketStorage = factory
|
|
184
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
184
185
|
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
185
186
|
|
|
186
187
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
@@ -268,7 +269,7 @@ bucket_definitions:
|
|
|
268
269
|
}
|
|
269
270
|
)
|
|
270
271
|
);
|
|
271
|
-
const bucketStorage = factory
|
|
272
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
272
273
|
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
273
274
|
|
|
274
275
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
@@ -337,7 +338,7 @@ bucket_definitions:
|
|
|
337
338
|
}
|
|
338
339
|
)
|
|
339
340
|
);
|
|
340
|
-
const bucketStorage = factory
|
|
341
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
341
342
|
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
342
343
|
|
|
343
344
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
@@ -407,7 +408,7 @@ bucket_definitions:
|
|
|
407
408
|
)
|
|
408
409
|
);
|
|
409
410
|
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
410
|
-
const bucketStorage = factory
|
|
411
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
411
412
|
|
|
412
413
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
413
414
|
const workspaceTable = await test_utils.resolveTestTable(writer, 'workspace', ['id'], config);
|
|
@@ -466,7 +467,7 @@ bucket_definitions:
|
|
|
466
467
|
)
|
|
467
468
|
);
|
|
468
469
|
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
469
|
-
const bucketStorage = factory
|
|
470
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
470
471
|
|
|
471
472
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
472
473
|
const workspaceTable = await test_utils.resolveTestTable(writer, 'workspace', undefined, config);
|
|
@@ -561,7 +562,7 @@ bucket_definitions:
|
|
|
561
562
|
)
|
|
562
563
|
);
|
|
563
564
|
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
564
|
-
const bucketStorage = factory
|
|
565
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
565
566
|
|
|
566
567
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
567
568
|
const workspaceTable = await test_utils.resolveTestTable(writer, 'workspace', undefined, config);
|
|
@@ -662,7 +663,7 @@ bucket_definitions:
|
|
|
662
663
|
}
|
|
663
664
|
)
|
|
664
665
|
);
|
|
665
|
-
const bucketStorage = factory
|
|
666
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
666
667
|
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
667
668
|
|
|
668
669
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
@@ -716,7 +717,7 @@ bucket_definitions:
|
|
|
716
717
|
}
|
|
717
718
|
)
|
|
718
719
|
);
|
|
719
|
-
const syncBucketStorage = bucketStorageFactory
|
|
720
|
+
const syncBucketStorage = await getTestStorage(bucketStorageFactory, syncRules);
|
|
720
721
|
|
|
721
722
|
const parsedSchema1 = syncBucketStorage.getParsedSyncRules({
|
|
722
723
|
defaultSchema: 'public'
|
|
@@ -754,7 +755,7 @@ streams:
|
|
|
754
755
|
WHERE data.foo = param.bar AND param.baz = auth.user_id()
|
|
755
756
|
`)
|
|
756
757
|
);
|
|
757
|
-
const bucketStorage = factory
|
|
758
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
758
759
|
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
759
760
|
|
|
760
761
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
@@ -826,7 +827,7 @@ streams:
|
|
|
826
827
|
}
|
|
827
828
|
)
|
|
828
829
|
);
|
|
829
|
-
const bucketStorage = factory
|
|
830
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
830
831
|
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
831
832
|
|
|
832
833
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
@@ -876,7 +877,7 @@ streams:
|
|
|
876
877
|
WHERE a.x = x.value AND y.value = auth.user_id()
|
|
877
878
|
`)
|
|
878
879
|
);
|
|
879
|
-
const bucketStorage = factory
|
|
880
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
880
881
|
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
881
882
|
|
|
882
883
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
@@ -1005,7 +1006,7 @@ streams:
|
|
|
1005
1006
|
query: SELECT * FROM b WHERE p IN (SELECT id FROM param_b WHERE u = auth.user_id())
|
|
1006
1007
|
`)
|
|
1007
1008
|
);
|
|
1008
|
-
const bucketStorage = factory
|
|
1009
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
1009
1010
|
const parsedSyncRules = syncRules.parsed(test_utils.PARSE_OPTIONS);
|
|
1010
1011
|
const hydrationState = parsedSyncRules.hydrationState;
|
|
1011
1012
|
const [parsedSyncConfig] = parsedSyncRules.syncConfigs;
|
|
@@ -1106,7 +1107,7 @@ streams:
|
|
|
1106
1107
|
}
|
|
1107
1108
|
)
|
|
1108
1109
|
);
|
|
1109
|
-
const bucketStorage = factory
|
|
1110
|
+
const bucketStorage = await getTestStorage(factory, replicationStream);
|
|
1110
1111
|
const sync_rules = syncRules.parsed(test_utils.PARSE_OPTIONS).hydratedSyncConfig;
|
|
1111
1112
|
|
|
1112
1113
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { storage, updateSyncRulesFromYaml } from '@powersync/service-core';
|
|
2
2
|
import { ScopedParameterLookup } from '@powersync/service-sync-rules';
|
|
3
3
|
import { expect, test } from 'vitest';
|
|
4
|
+
import { getTestStorage } from '../test-utils/leased-storage.js';
|
|
4
5
|
import * as test_utils from '../test-utils/test-utils-index.js';
|
|
5
6
|
import { compactActive } from './util.js';
|
|
6
7
|
|
|
@@ -17,7 +18,7 @@ bucket_definitions:
|
|
|
17
18
|
data: []
|
|
18
19
|
`)
|
|
19
20
|
);
|
|
20
|
-
const bucketStorage = factory
|
|
21
|
+
const bucketStorage = await getTestStorage(factory, syncRules);
|
|
21
22
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
22
23
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
23
24
|
|
|
@@ -99,7 +100,7 @@ bucket_definitions:
|
|
|
99
100
|
data: []
|
|
100
101
|
`)
|
|
101
102
|
);
|
|
102
|
-
const bucketStorage = factory
|
|
103
|
+
const bucketStorage = await getTestStorage(factory, syncRules);
|
|
103
104
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
104
105
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
105
106
|
|
|
@@ -13,6 +13,7 @@ import path from 'path';
|
|
|
13
13
|
import * as timers from 'timers/promises';
|
|
14
14
|
import { fileURLToPath } from 'url';
|
|
15
15
|
import { expect, test, vi } from 'vitest';
|
|
16
|
+
import { getTestStorage } from '../test-utils/leased-storage.js';
|
|
16
17
|
import * as test_utils from '../test-utils/test-utils-index.js';
|
|
17
18
|
import { bucketRequest, METRICS_HELPER } from '../test-utils/test-utils-index.js';
|
|
18
19
|
import { compactActive } from './util.js';
|
|
@@ -70,7 +71,7 @@ export function registerSyncTests(
|
|
|
70
71
|
content: BASIC_SYNC_RULES
|
|
71
72
|
});
|
|
72
73
|
|
|
73
|
-
const bucketStorage = f
|
|
74
|
+
const bucketStorage = await getTestStorage(f, syncRules);
|
|
74
75
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
75
76
|
const sourceTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
76
77
|
|
|
@@ -133,7 +134,7 @@ bucket_definitions:
|
|
|
133
134
|
`
|
|
134
135
|
});
|
|
135
136
|
|
|
136
|
-
const bucketStorage = f
|
|
137
|
+
const bucketStorage = await getTestStorage(f, syncRules);
|
|
137
138
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
138
139
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
139
140
|
|
|
@@ -192,7 +193,7 @@ streams:
|
|
|
192
193
|
`
|
|
193
194
|
});
|
|
194
195
|
|
|
195
|
-
const bucketStorage = f
|
|
196
|
+
const bucketStorage = await getTestStorage(f, syncRules);
|
|
196
197
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
197
198
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
198
199
|
|
|
@@ -273,7 +274,7 @@ bucket_definitions:
|
|
|
273
274
|
`
|
|
274
275
|
});
|
|
275
276
|
|
|
276
|
-
const bucketStorage = f
|
|
277
|
+
const bucketStorage = await getTestStorage(f, syncRules);
|
|
277
278
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
278
279
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
279
280
|
const syncRulesContent = syncRules.syncConfigContent[0];
|
|
@@ -451,7 +452,7 @@ bucket_definitions:
|
|
|
451
452
|
`
|
|
452
453
|
});
|
|
453
454
|
|
|
454
|
-
const bucketStorage = f
|
|
455
|
+
const bucketStorage = await getTestStorage(f, syncRules);
|
|
455
456
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
456
457
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
457
458
|
|
|
@@ -585,7 +586,7 @@ bucket_definitions:
|
|
|
585
586
|
`
|
|
586
587
|
});
|
|
587
588
|
|
|
588
|
-
const bucketStorage = f
|
|
589
|
+
const bucketStorage = await getTestStorage(f, syncRules);
|
|
589
590
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
590
591
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
591
592
|
const syncRulesContent = syncRules.syncConfigContent[0];
|
|
@@ -761,7 +762,7 @@ bucket_definitions:
|
|
|
761
762
|
const syncRules = await updateSyncRules(f, {
|
|
762
763
|
content: BASIC_SYNC_RULES
|
|
763
764
|
});
|
|
764
|
-
const bucketStorage = f
|
|
765
|
+
const bucketStorage = await getTestStorage(f, syncRules);
|
|
765
766
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
766
767
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
767
768
|
|
|
@@ -824,7 +825,7 @@ bucket_definitions:
|
|
|
824
825
|
content: BASIC_SYNC_RULES
|
|
825
826
|
});
|
|
826
827
|
|
|
827
|
-
const bucketStorage = await f
|
|
828
|
+
const bucketStorage = await await getTestStorage(f, syncRules);
|
|
828
829
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
829
830
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
830
831
|
|
|
@@ -869,7 +870,7 @@ bucket_definitions:
|
|
|
869
870
|
content: BASIC_SYNC_RULES
|
|
870
871
|
});
|
|
871
872
|
|
|
872
|
-
const bucketStorage = await f
|
|
873
|
+
const bucketStorage = await await getTestStorage(f, syncRules);
|
|
873
874
|
|
|
874
875
|
const stream = sync.streamResponse({
|
|
875
876
|
syncContext,
|
|
@@ -896,7 +897,7 @@ bucket_definitions:
|
|
|
896
897
|
content: BASIC_SYNC_RULES
|
|
897
898
|
});
|
|
898
899
|
|
|
899
|
-
const bucketStorage = await f
|
|
900
|
+
const bucketStorage = await await getTestStorage(f, syncRules);
|
|
900
901
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
901
902
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
902
903
|
// Activate
|
|
@@ -964,7 +965,7 @@ bucket_definitions:
|
|
|
964
965
|
`
|
|
965
966
|
});
|
|
966
967
|
|
|
967
|
-
const bucketStorage = await f
|
|
968
|
+
const bucketStorage = await await getTestStorage(f, syncRules);
|
|
968
969
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
969
970
|
const usersTable = await test_utils.resolveTestTable(writer, 'users', ['id'], config, 1);
|
|
970
971
|
|
|
@@ -1030,7 +1031,7 @@ bucket_definitions:
|
|
|
1030
1031
|
`
|
|
1031
1032
|
});
|
|
1032
1033
|
|
|
1033
|
-
const bucketStorage = await f
|
|
1034
|
+
const bucketStorage = await await getTestStorage(f, syncRules);
|
|
1034
1035
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1035
1036
|
const usersTable = await test_utils.resolveTestTable(writer, 'users', ['id'], config, 1);
|
|
1036
1037
|
const listsTable = await test_utils.resolveTestTable(writer, 'lists', ['id'], config, 2);
|
|
@@ -1105,7 +1106,7 @@ bucket_definitions:
|
|
|
1105
1106
|
`
|
|
1106
1107
|
});
|
|
1107
1108
|
|
|
1108
|
-
const bucketStorage = await f
|
|
1109
|
+
const bucketStorage = await await getTestStorage(f, syncRules);
|
|
1109
1110
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1110
1111
|
const usersTable = await test_utils.resolveTestTable(writer, 'users', ['id'], config, 1);
|
|
1111
1112
|
const listsTable = await test_utils.resolveTestTable(writer, 'lists', ['id'], config, 2);
|
|
@@ -1175,7 +1176,7 @@ bucket_definitions:
|
|
|
1175
1176
|
content: BASIC_SYNC_RULES
|
|
1176
1177
|
});
|
|
1177
1178
|
|
|
1178
|
-
const bucketStorage = await f
|
|
1179
|
+
const bucketStorage = await await getTestStorage(f, syncRules);
|
|
1179
1180
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1180
1181
|
// Activate
|
|
1181
1182
|
await writer.markAllSnapshotDone('0/0');
|
|
@@ -1215,7 +1216,7 @@ bucket_definitions:
|
|
|
1215
1216
|
content: BASIC_SYNC_RULES
|
|
1216
1217
|
});
|
|
1217
1218
|
|
|
1218
|
-
const bucketStorage = await f
|
|
1219
|
+
const bucketStorage = await await getTestStorage(f, syncRules);
|
|
1219
1220
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1220
1221
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
1221
1222
|
|
|
@@ -1306,7 +1307,7 @@ bucket_definitions:
|
|
|
1306
1307
|
content: BASIC_SYNC_RULES
|
|
1307
1308
|
});
|
|
1308
1309
|
|
|
1309
|
-
const bucketStorage = await f
|
|
1310
|
+
const bucketStorage = await await getTestStorage(f, syncRules);
|
|
1310
1311
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1311
1312
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
1312
1313
|
const bucket = bucketRequest(syncRules.syncConfigContent[0], 'mybucket[]').bucket;
|
|
@@ -1466,7 +1467,7 @@ bucket_definitions:
|
|
|
1466
1467
|
`
|
|
1467
1468
|
});
|
|
1468
1469
|
|
|
1469
|
-
const bucketStorage = await f
|
|
1470
|
+
const bucketStorage = await await getTestStorage(f, syncRules);
|
|
1470
1471
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1471
1472
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config);
|
|
1472
1473
|
const highPriorityBucket = bucketRequest(syncRules.syncConfigContent[0], 'high_priority[]').bucket;
|
|
@@ -1593,7 +1594,7 @@ bucket_definitions:
|
|
|
1593
1594
|
content: BASIC_SYNC_RULES
|
|
1594
1595
|
});
|
|
1595
1596
|
|
|
1596
|
-
const bucketStorage = f
|
|
1597
|
+
const bucketStorage = await getTestStorage(f, syncRules);
|
|
1597
1598
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1598
1599
|
|
|
1599
1600
|
await writer.markAllSnapshotDone('0/1');
|
|
@@ -1679,7 +1680,7 @@ config:
|
|
|
1679
1680
|
const syncRules = await updateSyncRules(f, {
|
|
1680
1681
|
content: rules[i]
|
|
1681
1682
|
});
|
|
1682
|
-
const bucketStorage = f
|
|
1683
|
+
const bucketStorage = await getTestStorage(f, syncRules);
|
|
1683
1684
|
await using writer = await bucketStorage.createWriter(test_utils.BATCH_OPTIONS);
|
|
1684
1685
|
|
|
1685
1686
|
const testTable = await test_utils.resolveTestTable(writer, 'test', ['id'], config, i + 1);
|