MCPcopy Create free account
hub / github.com/cloudbase/garm / TestDeleteEntityPoolRemovesFromGlobalMap

Method TestDeleteEntityPoolRemovesFromGlobalMap

cache/cache_test.go:1441–1478  ·  view source on GitHub ↗

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.

()

Source from the content-addressed store, hash-verified

1439// in the global maps (e.pools, e.scalesets) after deletion.
1440
1441func (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
1480func (c *CacheTestSuite) TestDeleteEntityScaleSetRemovesFromGlobalMap() {
1481 entity := params.ForgeEntity{

Callers

nothing calls this directly

Calls 7

SetEntityFunction · 0.85
SetEntityPoolFunction · 0.85
GetAllPoolsFunction · 0.85
GetPoolByIDFunction · 0.85
DeleteEntityPoolFunction · 0.85
GetEntityPoolsFunction · 0.85
LenMethod · 0.65

Tested by

no test coverage detected