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

Method TestTimedOutToolsCache

cache/cache_test.go:118–140  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

116}
117
118func (c *CacheTestSuite) TestTimedOutToolsCache() {
119 tools := []commonParams.RunnerApplicationDownload{
120 {
121 DownloadURL: garmTesting.Ptr("https://example.com"),
122 },
123 }
124
125 c.Require().NotNil(githubToolsCache)
126 c.Require().Len(githubToolsCache.entities, 0)
127 SetGithubToolsCache(c.entity, tools)
128 entity := githubToolsCache.entities[c.entity.ID]
129
130 c.Require().Equal(int64(entity.expiresAt.Sub(entity.updatedAt).Minutes()), int64(60))
131 c.Require().Len(githubToolsCache.entities, 1)
132 entity = githubToolsCache.entities[c.entity.ID]
133 entity.updatedAt = entity.updatedAt.Add(-3 * time.Hour)
134 entity.expiresAt = entity.updatedAt.Add(-2 * time.Hour)
135 githubToolsCache.entities[c.entity.ID] = entity
136
137 cachedTools, err := GetGithubToolsCache(c.entity.ID)
138 c.Require().Error(err)
139 c.Require().Nil(cachedTools)
140}
141
142func (c *CacheTestSuite) TestGetInexistentCache() {
143 c.Require().NotNil(githubToolsCache)

Callers

nothing calls this directly

Calls 5

SetGithubToolsCacheFunction · 0.85
GetGithubToolsCacheFunction · 0.85
AddMethod · 0.80
LenMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected