| 306 | } |
| 307 | |
| 308 | func TestUpdatesSaved(t *testing.T) { |
| 309 | // unlike most tests these are applied serially to the same list object and the expected |
| 310 | // results are cumulative across all tests |
| 311 | |
| 312 | one := uuid.MustParse("00000000-0000-0000-0000-000000000001") |
| 313 | two := uuid.MustParse("00000000-0000-0000-0000-000000000002") |
| 314 | oneOhOne := uuid.MustParse("10000000-0000-0000-0000-000000000001") |
| 315 | oneOhTwo := uuid.MustParse("10000000-0000-0000-0000-000000000002") |
| 316 | |
| 317 | tests := []struct { |
| 318 | applyMetas PerTenant |
| 319 | applyCompacted PerTenantCompacted |
| 320 | updateTenant string |
| 321 | addMetas []*backend.BlockMeta |
| 322 | removeMetas []*backend.BlockMeta |
| 323 | addCompacted []*backend.CompactedBlockMeta |
| 324 | |
| 325 | expectedTenants []string |
| 326 | expectedMetas PerTenant |
| 327 | expectedCompacted PerTenantCompacted |
| 328 | }{ |
| 329 | // STEP 1: apply a normal polling data and updates |
| 330 | { |
| 331 | applyMetas: PerTenant{ |
| 332 | "test": []*backend.BlockMeta{ |
| 333 | { |
| 334 | BlockID: backend.UUID(one), |
| 335 | }, |
| 336 | }, |
| 337 | }, |
| 338 | applyCompacted: PerTenantCompacted{ |
| 339 | "test": []*backend.CompactedBlockMeta{ |
| 340 | { |
| 341 | BlockMeta: backend.BlockMeta{ |
| 342 | BlockID: backend.UUID(oneOhOne), |
| 343 | }, |
| 344 | }, |
| 345 | }, |
| 346 | }, |
| 347 | updateTenant: "test", |
| 348 | addMetas: []*backend.BlockMeta{ |
| 349 | { |
| 350 | BlockID: backend.UUID(one), |
| 351 | }, |
| 352 | { |
| 353 | BlockID: backend.UUID(two), |
| 354 | }, |
| 355 | }, |
| 356 | removeMetas: []*backend.BlockMeta{ |
| 357 | { |
| 358 | BlockID: backend.UUID(one), |
| 359 | }, |
| 360 | }, |
| 361 | addCompacted: []*backend.CompactedBlockMeta{ |
| 362 | { |
| 363 | BlockMeta: backend.BlockMeta{ |
| 364 | BlockID: backend.UUID(oneOhTwo), |
| 365 | }, |