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

Method TestSetGetEntityCache

cache/cache_test.go:314–344  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

312}
313
314func (c *CacheTestSuite) TestSetGetEntityCache() {
315 entity := params.ForgeEntity{
316 ID: "test-entity",
317 EntityType: params.ForgeEntityTypeOrganization,
318 Name: "test",
319 Owner: "test",
320 }
321 SetEntity(entity)
322 cachedEntity, ok := GetEntity("test-entity")
323 c.Require().True(ok)
324 c.Require().Equal(entity.ID, cachedEntity.ID)
325
326 pool := params.Pool{
327 ID: "pool-1",
328 OrgID: "test-entity",
329 }
330 SetEntityPool(entity.ID, pool)
331 cachedEntityPools := GetEntityPools("test-entity")
332 c.Require().Equal(1, len(cachedEntityPools))
333
334 entity.Credentials.Description = "test description"
335 SetEntity(entity)
336 cachedEntity, ok = GetEntity("test-entity")
337 c.Require().True(ok)
338 c.Require().Equal(entity.ID, cachedEntity.ID)
339 c.Require().Equal(entity.Credentials.Description, cachedEntity.Credentials.Description)
340
341 // Make sure we don't clobber pools after updating the entity
342 cachedEntityPools = GetEntityPools("test-entity")
343 c.Require().Equal(1, len(cachedEntityPools))
344}
345
346func (c *CacheTestSuite) TestReplaceEntityPools() {
347 entity := params.ForgeEntity{

Callers

nothing calls this directly

Calls 4

SetEntityFunction · 0.85
GetEntityFunction · 0.85
SetEntityPoolFunction · 0.85
GetEntityPoolsFunction · 0.85

Tested by

no test coverage detected