| 872 | } |
| 873 | |
| 874 | func TestIterateOnResetCache(t *testing.T) { |
| 875 | t.Parallel() |
| 876 | |
| 877 | // given |
| 878 | cache, _ := New(context.Background(), Config{ |
| 879 | Shards: 8, |
| 880 | LifeWindow: time.Second, |
| 881 | MaxEntriesInWindow: 1, |
| 882 | MaxEntrySize: 256, |
| 883 | }) |
| 884 | keys := 1337 |
| 885 | |
| 886 | // when |
| 887 | for i := 0; i < keys; i++ { |
| 888 | cache.Set(fmt.Sprintf("key%d", i), []byte("value")) |
| 889 | } |
| 890 | cache.Reset() |
| 891 | |
| 892 | // then |
| 893 | iterator := cache.Iterator() |
| 894 | |
| 895 | assertEqual(t, false, iterator.SetNext()) |
| 896 | } |
| 897 | |
| 898 | func TestGetOnResetCache(t *testing.T) { |
| 899 | t.Parallel() |