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

Method TestGetEntityForInstanceWithPool

cache/cache_test.go:1232–1262  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1230}
1231
1232func (c *CacheTestSuite) TestGetEntityForInstanceWithPool() {
1233 entity := params.ForgeEntity{
1234 ID: "test-entity",
1235 EntityType: params.ForgeEntityTypeOrganization,
1236 Name: "test-org",
1237 Owner: "test-owner",
1238 }
1239 pool := params.Pool{
1240 ID: "pool-1",
1241 OrgID: "test-entity",
1242 }
1243 instance := params.Instance{
1244 Name: "test-instance",
1245 PoolID: "pool-1",
1246 }
1247
1248 SetEntity(entity)
1249 SetEntityPool(entity.ID, pool)
1250 SetInstanceCache(instance)
1251
1252 retrievedEntity, ok := GetEntityForInstance("test-instance")
1253 c.Require().True(ok)
1254 c.Require().Equal(entity.ID, retrievedEntity.ID)
1255 c.Require().Equal(entity.Name, retrievedEntity.Name)
1256 c.Require().Equal(entity.Owner, retrievedEntity.Owner)
1257 c.Require().Equal(entity.EntityType, retrievedEntity.EntityType)
1258
1259 nonExistentEntity, ok := GetEntityForInstance("non-existent-instance")
1260 c.Require().False(ok)
1261 c.Require().Equal(params.ForgeEntity{}, nonExistentEntity)
1262}
1263
1264func (c *CacheTestSuite) TestGetEntityForInstanceWithScaleSet() {
1265 entity := params.ForgeEntity{

Callers

nothing calls this directly

Calls 4

SetEntityFunction · 0.85
SetEntityPoolFunction · 0.85
SetInstanceCacheFunction · 0.85
GetEntityForInstanceFunction · 0.85

Tested by

no test coverage detected