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

Function testJson

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

Source from the content-addressed store, hash-verified

23})
24
25async function testJson() {
26 // basic get set checks
27 await bucketJson.set("1", {
28 a: 10,
29 b: "hello"
30 })
31
32 const entry = await bucketJson.get("1")
33 assertExpected(10, entry?.value.a)
34 assertExpected("hello", entry?.value.b)
35
36 const count = await bucketJson.count()
37 assertExpected(1, count)
38
39 // ensure this didn't touch the plugin bucket
40 const countInPlugin = await bucketJsonPlugin.count()
41 assertExpected(0, countInPlugin)
42 const entryInPlugin = await bucketJsonPlugin.get("1")
43 assertExpected(undefined, entryInPlugin)
44 let results = await bucketJsonPlugin.list({})
45 assertExpected(0, results.length)
46
47 // ensure that touching the plugin bucket does not touch the guild bucket
48 await bucketJsonPlugin.set("1", {
49 a: 20,
50 b: "world"
51 })
52
53 const entryPlugin = await bucketJsonPlugin.get("1")
54 assertExpected(20, entryPlugin?.value.a)
55 assertExpected("world", entryPlugin?.value.b)
56
57 const entryGuild = await bucketJson.get("1")
58 assertExpected(10, entryGuild?.value.a)
59 assertExpected("hello", entryGuild?.value.b)
60
61 // check delete all
62 await bucketJsonPlugin.deleteAll()
63 assertExpected(await bucketJsonPlugin.count(), 0)
64 assertExpected(await bucketJson.count(), 1)
65
66 await bucketJsonPlugin.set("1", { a: 30, b: "!" })
67 await bucketJson.deleteAll()
68 assertExpected(await bucketJsonPlugin.count(), 1)
69 assertExpected(await bucketJson.count(), 0)
70
71 // reset
72 await bucketJson.set("1", { a: 40, b: "wahoo" })
73
74 // check single delete
75 await bucketJsonPlugin.delete("1")
76
77 assertExpected(await bucketJsonPlugin.count(), 0)
78 assertExpected(await bucketJson.count(), 1)
79
80 await bucketJsonPlugin.set("1", { a: 30, b: "!" })
81
82 await bucketJson.delete("1")

Callers 1

storagev2.tsFile · 0.85

Calls 6

assertExpectedFunction · 0.90
countMethod · 0.80
deleteAllMethod · 0.80
setMethod · 0.45
getMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected