(t *testing.T)
| 229 | } |
| 230 | |
| 231 | func TestList(t *testing.T) { |
| 232 | tenantID := "test" |
| 233 | blockID := uuid.New() |
| 234 | |
| 235 | tests := []struct { |
| 236 | name string |
| 237 | readerList []string |
| 238 | expectedList []string |
| 239 | expectedCache []string |
| 240 | }{ |
| 241 | { |
| 242 | name: "list passthrough", |
| 243 | readerList: []string{"1"}, |
| 244 | expectedList: []string{"1"}, |
| 245 | expectedCache: nil, |
| 246 | }, |
| 247 | } |
| 248 | |
| 249 | for _, tt := range tests { |
| 250 | t.Run(tt.name, func(t *testing.T) { |
| 251 | mockR := &backend.MockRawReader{ |
| 252 | L: tt.readerList, |
| 253 | } |
| 254 | mockW := &backend.MockRawWriter{} |
| 255 | |
| 256 | rw, _, _ := NewCache(nil, mockR, mockW, test.NewMockProvider(), log.NewNopLogger()) |
| 257 | |
| 258 | ctx := context.Background() |
| 259 | list, _ := rw.List(ctx, backend.KeyPathForBlock(blockID, tenantID)) |
| 260 | assert.Equal(t, tt.expectedList, list) |
| 261 | |
| 262 | // clear reader and re-request. things should be cached! |
| 263 | mockR.L = nil |
| 264 | |
| 265 | // list is not cached |
| 266 | list, _ = rw.List(ctx, backend.KeyPathForBlock(blockID, tenantID)) |
| 267 | assert.Equal(t, tt.expectedCache, list) |
| 268 | }) |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | func TestCacheKeys(t *testing.T) { |
| 273 | provider := test.NewMockProvider() |
nothing calls this directly
no test coverage detected