(t *testing.T)
| 132 | } |
| 133 | |
| 134 | func (s) TestDataCache_AddForcesResize(t *testing.T) { |
| 135 | initCacheEntries() |
| 136 | dc := newDataCache(1, nil, "") |
| 137 | |
| 138 | // The first entry in cacheEntries has a minimum expiry time in the future. |
| 139 | // This entry would stop the resize operation since we do not evict entries |
| 140 | // whose minimum expiration time is in the future. So, we do not use that |
| 141 | // entry in this test. The entry being added has a running backoff timer. |
| 142 | evicted, ok := dc.addEntry(cacheKeys[1], cacheEntries[1]) |
| 143 | if evicted || !ok { |
| 144 | t.Fatalf("dataCache.addEntry() returned (%v, %v) want (false, true)", evicted, ok) |
| 145 | } |
| 146 | |
| 147 | // Add another entry leading to the eviction of the above entry which has a |
| 148 | // running backoff timer. The first return value is expected to be true. |
| 149 | backoffCancelled, ok := dc.addEntry(cacheKeys[2], cacheEntries[2]) |
| 150 | if !backoffCancelled || !ok { |
| 151 | t.Fatalf("dataCache.addEntry() returned (%v, %v) want (true, true)", backoffCancelled, ok) |
| 152 | } |
| 153 | |
| 154 | // Add another entry leading to the eviction of the above entry which does not |
| 155 | // have a running backoff timer. This should evict the above entry, but the |
| 156 | // first return value is expected to be false. |
| 157 | backoffCancelled, ok = dc.addEntry(cacheKeys[3], cacheEntries[3]) |
| 158 | if backoffCancelled || !ok { |
| 159 | t.Fatalf("dataCache.addEntry() returned (%v, %v) want (false, true)", backoffCancelled, ok) |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | func (s) TestDataCache_Resize(t *testing.T) { |
| 164 | initCacheEntries() |
nothing calls this directly
no test coverage detected