MCPcopy Create free account
hub / github.com/GoEdgeLab/EdgeNode / TestQuery_FindAll_Break

Function TestQuery_FindAll_Break

internal/utils/kvstore/query_test.go:41–70  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

39}
40
41func TestQuery_FindAll_Break(t *testing.T) {
42 var table = testOpenStoreTable[*testCachedItem](t, "cache_items", &testCacheItemEncoder[*testCachedItem]{})
43
44 defer func() {
45 _ = testingStore.Close()
46 }()
47
48 var before = time.Now()
49 defer func() {
50 t.Log("cost:", time.Since(before).Seconds()*1000, "ms")
51 }()
52
53 var count int
54 err := table.
55 Query().
56 FindAll(func(tx *kvstore.Tx[*testCachedItem], item kvstore.Item[*testCachedItem]) (goNext bool, err error) {
57 t.Log("key:", item.Key, "value:", item.Value)
58 count++
59
60 if count > 2 {
61 // break test
62 _ = table.DB().Store().Close()
63 }
64
65 return count < 3, nil
66 })
67 if err != nil {
68 t.Log(err)
69 }
70}
71
72func TestQuery_FindAll_Break_Closed(t *testing.T) {
73 var table = testOpenStoreTable[*testCachedItem](t, "cache_items", &testCacheItemEncoder[*testCachedItem]{})

Callers

nothing calls this directly

Calls 6

LogMethod · 0.80
FindAllMethod · 0.80
StoreMethod · 0.80
DBMethod · 0.80
CloseMethod · 0.65
QueryMethod · 0.45

Tested by

no test coverage detected