MCPcopy Create free account
hub / github.com/Botloader/botloader / testGetDelKeys

Function testGetDelKeys

integration-tests/tasks_get_del_bucket.ts:25–58  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

23})
24
25async function testGetDelKeys() {
26 let task1 = await bucket.schedule({ executeAt: new Date(Date.now() + 1000000), key: "1" });
27 let task2 = await bucket.schedule({ executeAt: new Date(Date.now() + 1000000), key: "2" });
28 let taskOtherNs = await anotherBucket.schedule({ executeAt: new Date(Date.now() + 1000000), key: "1" });
29 let taskOtherPlugin = await bucketPluginCustom.schedule({ executeAt: new Date(Date.now() + 1000000), key: "1" });
30
31 assetJsonEquals(await Tasks.getById(task1.id), task1);
32 assetJsonEquals(await Tasks.getById(task2.id), task2);
33 assetJsonEquals(await Tasks.getById(taskOtherNs.id), taskOtherNs);
34 assetJsonEquals(await Tasks.getById(taskOtherPlugin.id), taskOtherPlugin);
35
36 assetJsonEquals(await bucket.getByKey("1"), task1);
37 assetJsonEquals(await bucket.getByKey("2"), task2);
38 assetJsonEquals(await anotherBucket.getByKey("1"), taskOtherNs);
39 assetJsonEquals(await bucketPluginCustom.getByKey("1"), taskOtherPlugin);
40
41 // test deleteAll while cleaning up
42
43 // deleting the guild scoped bucket and ensuring it only deleted that
44 await bucket.deleteAll()
45 assertExpected(undefined, await bucket.getByKey("1"))
46 assertExpected(undefined, await bucket.getByKey("2"))
47
48 assetJsonEquals(taskOtherNs, await anotherBucket.getByKey("1"));
49 assetJsonEquals(taskOtherPlugin, await bucketPluginCustom.getByKey("1"));
50
51 // deleting plugin scoped bucket and ensuring it did not touch the guild one
52 await bucketPluginCustom.deleteAll()
53 assetJsonEquals(taskOtherNs, await anotherBucket.getByKey("1"));
54 assertExpected(undefined, await bucketPluginCustom.getByKey("1"));
55
56 await anotherBucket.deleteAll()
57 assertExpected(undefined, await anotherBucket.getByKey("1"));
58}
59
60async function testGetAll() {
61 for (let i = 0; i < 55; i++) {

Callers 1

Calls 6

assetJsonEqualsFunction · 0.90
assertExpectedFunction · 0.90
scheduleMethod · 0.80
getByIdMethod · 0.80
getByKeyMethod · 0.80
deleteAllMethod · 0.80

Tested by

no test coverage detected