(t *testing.T)
| 837 | } |
| 838 | |
| 839 | func TestCacheReset(t *testing.T) { |
| 840 | t.Parallel() |
| 841 | |
| 842 | // given |
| 843 | cache, _ := New(context.Background(), Config{ |
| 844 | Shards: 8, |
| 845 | LifeWindow: time.Second, |
| 846 | MaxEntriesInWindow: 1, |
| 847 | MaxEntrySize: 256, |
| 848 | }) |
| 849 | keys := 1337 |
| 850 | |
| 851 | // when |
| 852 | for i := 0; i < keys; i++ { |
| 853 | cache.Set(fmt.Sprintf("key%d", i), []byte("value")) |
| 854 | } |
| 855 | |
| 856 | // then |
| 857 | assertEqual(t, keys, cache.Len()) |
| 858 | |
| 859 | // and when |
| 860 | cache.Reset() |
| 861 | |
| 862 | // then |
| 863 | assertEqual(t, 0, cache.Len()) |
| 864 | |
| 865 | // and when |
| 866 | for i := 0; i < keys; i++ { |
| 867 | cache.Set(fmt.Sprintf("key%d", i), []byte("value")) |
| 868 | } |
| 869 | |
| 870 | // then |
| 871 | assertEqual(t, keys, cache.Len()) |
| 872 | } |
| 873 | |
| 874 | func TestIterateOnResetCache(t *testing.T) { |
| 875 | t.Parallel() |
nothing calls this directly
no test coverage detected
searching dependent graphs…