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

Method TestSetToolsCacheWithError

cache/cache_test.go:85–103  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

83}
84
85func (c *CacheTestSuite) TestSetToolsCacheWithError() {
86 tools := []commonParams.RunnerApplicationDownload{
87 {
88 DownloadURL: garmTesting.Ptr("https://example.com"),
89 },
90 }
91 c.Require().NotNil(githubToolsCache)
92 c.Require().Len(githubToolsCache.entities, 0)
93 SetGithubToolsCache(c.entity, tools)
94 entity := githubToolsCache.entities[c.entity.ID]
95
96 c.Require().Equal(int64(entity.expiresAt.Sub(entity.updatedAt).Minutes()), int64(60))
97 c.Require().Len(githubToolsCache.entities, 1)
98 SetGithubToolsCacheError(c.entity, runnerErrors.ErrNotFound)
99
100 cachedTools, err := GetGithubToolsCache(c.entity.ID)
101 c.Require().Error(err)
102 c.Require().Nil(cachedTools)
103}
104
105func (c *CacheTestSuite) TestSetErrorOnNonExistingCacheEntity() {
106 entity := params.ForgeEntity{

Callers

nothing calls this directly

Calls 5

SetGithubToolsCacheFunction · 0.85
SetGithubToolsCacheErrorFunction · 0.85
GetGithubToolsCacheFunction · 0.85
LenMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected