| 39 | } |
| 40 | |
| 41 | func 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 | |
| 72 | func TestQuery_FindAll_Break_Closed(t *testing.T) { |
| 73 | var table = testOpenStoreTable[*testCachedItem](t, "cache_items", &testCacheItemEncoder[*testCachedItem]{}) |