Tests for pool/scaleset cleanup on delete operations. These cover bugs where deleted pools and scale sets remained in the global maps (e.pools, e.scalesets) after deletion.
()
| 1439 | // in the global maps (e.pools, e.scalesets) after deletion. |
| 1440 | |
| 1441 | func (c *CacheTestSuite) TestDeleteEntityPoolRemovesFromGlobalMap() { |
| 1442 | entity := params.ForgeEntity{ |
| 1443 | ID: "test-entity", |
| 1444 | EntityType: params.ForgeEntityTypeOrganization, |
| 1445 | Name: "test", |
| 1446 | Owner: "test", |
| 1447 | } |
| 1448 | pool := params.Pool{ |
| 1449 | ID: "pool-1", |
| 1450 | OrgID: "test-entity", |
| 1451 | CreatedAt: time.Now(), |
| 1452 | } |
| 1453 | |
| 1454 | SetEntity(entity) |
| 1455 | SetEntityPool(entity.ID, pool) |
| 1456 | |
| 1457 | // Pool should be in both entity index and global map. |
| 1458 | pools := GetAllPools() |
| 1459 | c.Require().Len(pools, 1) |
| 1460 | c.Require().Equal("pool-1", pools[0].ID) |
| 1461 | |
| 1462 | _, ok := GetPoolByID("pool-1") |
| 1463 | c.Require().True(ok) |
| 1464 | |
| 1465 | // Delete the pool. |
| 1466 | DeleteEntityPool(entity.ID, pool.ID) |
| 1467 | |
| 1468 | // Pool must be gone from entity index. |
| 1469 | entityPools := GetEntityPools(entity.ID) |
| 1470 | c.Require().Len(entityPools, 0) |
| 1471 | |
| 1472 | // Pool must also be gone from the global map. |
| 1473 | pools = GetAllPools() |
| 1474 | c.Require().Len(pools, 0) |
| 1475 | |
| 1476 | _, ok = GetPoolByID("pool-1") |
| 1477 | c.Require().False(ok) |
| 1478 | } |
| 1479 | |
| 1480 | func (c *CacheTestSuite) TestDeleteEntityScaleSetRemovesFromGlobalMap() { |
| 1481 | entity := params.ForgeEntity{ |
nothing calls this directly
no test coverage detected