Skip to content

Commit d91c383

Browse files
committed
Add tests
1 parent e94057e commit d91c383

File tree

15 files changed

+479
-115
lines changed

15 files changed

+479
-115
lines changed

modules/module-mongodb-storage/test/src/__snapshots__/storage_sync.test.ts.snap

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,116 @@ exports[`sync - mongodb > compacting data - invalidate checkpoint 2`] = `
104104
]
105105
`;
106106

107+
exports[`sync - mongodb > encodes sync rules id in buckes for streams 1`] = `
108+
[
109+
{
110+
"checkpoint": {
111+
"buckets": [
112+
{
113+
"bucket": "1#test|0[]",
114+
"checksum": 920318466,
115+
"count": 1,
116+
"priority": 3,
117+
"subscriptions": [
118+
{
119+
"default": 0,
120+
},
121+
],
122+
},
123+
],
124+
"last_op_id": "1",
125+
"streams": [
126+
{
127+
"errors": [],
128+
"is_default": true,
129+
"name": "test",
130+
},
131+
],
132+
"write_checkpoint": undefined,
133+
},
134+
},
135+
{
136+
"data": {
137+
"after": "0",
138+
"bucket": "1#test|0[]",
139+
"data": [
140+
{
141+
"checksum": 920318466,
142+
"data": "{"id":"t1","description":"Test 1"}",
143+
"object_id": "t1",
144+
"object_type": "test",
145+
"op": "PUT",
146+
"op_id": "1",
147+
"subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
148+
},
149+
],
150+
"has_more": false,
151+
"next_after": "1",
152+
},
153+
},
154+
{
155+
"checkpoint_complete": {
156+
"last_op_id": "1",
157+
},
158+
},
159+
]
160+
`;
161+
162+
exports[`sync - mongodb > encodes sync rules id in buckes for streams 2`] = `
163+
[
164+
{
165+
"checkpoint": {
166+
"buckets": [
167+
{
168+
"bucket": "2#test|0[]",
169+
"checksum": 920318466,
170+
"count": 1,
171+
"priority": 3,
172+
"subscriptions": [
173+
{
174+
"default": 0,
175+
},
176+
],
177+
},
178+
],
179+
"last_op_id": "2",
180+
"streams": [
181+
{
182+
"errors": [],
183+
"is_default": true,
184+
"name": "test",
185+
},
186+
],
187+
"write_checkpoint": undefined,
188+
},
189+
},
190+
{
191+
"data": {
192+
"after": "0",
193+
"bucket": "2#test|0[]",
194+
"data": [
195+
{
196+
"checksum": 920318466,
197+
"data": "{"id":"t1","description":"Test 1"}",
198+
"object_id": "t1",
199+
"object_type": "test",
200+
"op": "PUT",
201+
"op_id": "2",
202+
"subkey": "e5aa2ddc-1328-58fa-a000-0b5ed31eaf1a",
203+
},
204+
],
205+
"has_more": false,
206+
"next_after": "2",
207+
},
208+
},
209+
{
210+
"checkpoint_complete": {
211+
"last_op_id": "2",
212+
},
213+
},
214+
]
215+
`;
216+
107217
exports[`sync - mongodb > expired token 1`] = `
108218
[
109219
{

modules/module-postgres-storage/test/src/__snapshots__/storage_sync.test.ts.snap

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,116 @@ exports[`sync - postgres > compacting data - invalidate checkpoint 2`] = `
104104
]
105105
`;
106106

107+
exports[`sync - postgres > encodes sync rules id in buckes for streams 1`] = `
108+
[
109+
{
110+
"checkpoint": {
111+
"buckets": [
112+
{
113+
"bucket": "1#test|0[]",
114+
"checksum": 920318466,
115+
"count": 1,
116+
"priority": 3,
117+
"subscriptions": [
118+
{
119+
"default": 0,
120+
},
121+
],
122+
},
123+
],
124+
"last_op_id": "1",
125+
"streams": [
126+
{
127+
"errors": [],
128+
"is_default": true,
129+
"name": "test",
130+
},
131+
],
132+
"write_checkpoint": undefined,
133+
},
134+
},
135+
{
136+
"data": {
137+
"after": "0",
138+
"bucket": "1#test|0[]",
139+
"data": [
140+
{
141+
"checksum": 920318466,
142+
"data": "{"id":"t1","description":"Test 1"}",
143+
"object_id": "t1",
144+
"object_type": "test",
145+
"op": "PUT",
146+
"op_id": "1",
147+
"subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
148+
},
149+
],
150+
"has_more": false,
151+
"next_after": "1",
152+
},
153+
},
154+
{
155+
"checkpoint_complete": {
156+
"last_op_id": "1",
157+
},
158+
},
159+
]
160+
`;
161+
162+
exports[`sync - postgres > encodes sync rules id in buckes for streams 2`] = `
163+
[
164+
{
165+
"checkpoint": {
166+
"buckets": [
167+
{
168+
"bucket": "2#test|0[]",
169+
"checksum": 920318466,
170+
"count": 1,
171+
"priority": 3,
172+
"subscriptions": [
173+
{
174+
"default": 0,
175+
},
176+
],
177+
},
178+
],
179+
"last_op_id": "2",
180+
"streams": [
181+
{
182+
"errors": [],
183+
"is_default": true,
184+
"name": "test",
185+
},
186+
],
187+
"write_checkpoint": undefined,
188+
},
189+
},
190+
{
191+
"data": {
192+
"after": "0",
193+
"bucket": "2#test|0[]",
194+
"data": [
195+
{
196+
"checksum": 920318466,
197+
"data": "{"id":"t1","description":"Test 1"}",
198+
"object_id": "t1",
199+
"object_type": "test",
200+
"op": "PUT",
201+
"op_id": "2",
202+
"subkey": "02d285ac-4f96-5124-8fba-c6d1df992dd1",
203+
},
204+
],
205+
"has_more": false,
206+
"next_after": "2",
207+
},
208+
},
209+
{
210+
"checkpoint_complete": {
211+
"last_op_id": "2",
212+
},
213+
},
214+
]
215+
`;
216+
107217
exports[`sync - postgres > expired token 1`] = `
108218
[
109219
{

packages/service-core-tests/src/test-utils/general-utils.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ export function querierOptions(globalParameters: RequestParameters): GetQuerierO
107107
return {
108108
globalParameters,
109109
hasDefaultStreams: true,
110-
streams: {}
110+
streams: {},
111+
bucketIdTransformer: SqlSyncRules.versionedBucketIdTransformer('1')
111112
};
112113
}

0 commit comments

Comments
 (0)