Skip to content

Commit 6a6486d

Browse files
committed
job cursor content filter all test
1 parent e00f09e commit 6a6486d

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

test/unit/flavors/job.test.js

+61
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,56 @@ describe('flavors/job.js', () => {
255255
.done(done);
256256
});
257257

258+
it('should continue - all filtered', (done) => {
259+
sinon.stub(DynamoDBConnector.prototype, 'queryPage')
260+
.onCall(0)
261+
.resolves({
262+
Items: [
263+
{
264+
pk: '3',
265+
sk: 'thing',
266+
name: 'thing 3',
267+
},
268+
],
269+
});
270+
271+
const events = toDynamodbRecords([
272+
{
273+
timestamp: 1572832694,
274+
keys: {
275+
pk: '1',
276+
sk: 'job',
277+
},
278+
newImage: {
279+
pk: '1',
280+
sk: 'job',
281+
discriminator: 'job',
282+
cursor: {
283+
pk: '2',
284+
sk: 'thing',
285+
},
286+
},
287+
oldImage: {
288+
pk: '1',
289+
sk: 'job',
290+
discriminator: 'job',
291+
},
292+
},
293+
]);
294+
295+
initialize({
296+
...initializeFrom([filterAllRule]),
297+
}, { ...defaultOptions, AES: false })
298+
.assemble(fromDynamodb(events), false)
299+
.collect()
300+
// .tap((collected) => console.log(JSON.stringify(collected, null, 2)))
301+
.tap((collected) => {
302+
// unlucky filter all drops cursor
303+
expect(collected.length).to.equal(0);
304+
})
305+
.done(done);
306+
});
307+
258308
it('should stop', (done) => {
259309
const events = toDynamodbRecords([
260310
{
@@ -344,3 +394,14 @@ const rules = [
344394
toCursorUpdateRequest,
345395
},
346396
];
397+
398+
const filterAllRule = {
399+
id: 'job1-continued',
400+
eventType: 'job-updated',
401+
jobFilters: [(uow) => uow.event?.raw?.new?.cursor],
402+
filters: [() => false],
403+
flavor: job,
404+
toQuerySplitRequest,
405+
toEvent,
406+
toCursorUpdateRequest,
407+
};

0 commit comments

Comments
 (0)