()
| 312 | } |
| 313 | |
| 314 | func (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 | |
| 346 | func (c *CacheTestSuite) TestReplaceEntityPools() { |
| 347 | entity := params.ForgeEntity{ |
nothing calls this directly
no test coverage detected