| 70 | } |
| 71 | |
| 72 | func TestQuery_FindAll_Break_Closed(t *testing.T) { |
| 73 | var table = testOpenStoreTable[*testCachedItem](t, "cache_items", &testCacheItemEncoder[*testCachedItem]{}) |
| 74 | |
| 75 | defer func() { |
| 76 | _ = testingStore.Close() |
| 77 | }() |
| 78 | |
| 79 | var before = time.Now() |
| 80 | defer func() { |
| 81 | t.Log("cost:", time.Since(before).Seconds()*1000, "ms") |
| 82 | }() |
| 83 | |
| 84 | var count int |
| 85 | err := table. |
| 86 | Query(). |
| 87 | FindAll(func(tx *kvstore.Tx[*testCachedItem], item kvstore.Item[*testCachedItem]) (goNext bool, err error) { |
| 88 | t.Log("key:", item.Key, "value:", item.Value) |
| 89 | count++ |
| 90 | |
| 91 | if count > 2 { |
| 92 | // break test |
| 93 | _ = table.DB().Store().Close() |
| 94 | } |
| 95 | |
| 96 | return count < 3, nil |
| 97 | }) |
| 98 | t.Log("expected error:", err) |
| 99 | } |
| 100 | |
| 101 | func TestQuery_FindAll_Desc(t *testing.T) { |
| 102 | var table = testOpenStoreTable[*testCachedItem](t, "cache_items", &testCacheItemEncoder[*testCachedItem]{}) |