MCPcopy Index your code
hub / github.com/docker/docker-agent / TestFileCache_missingFileIsFine

Function TestFileCache_missingFileIsFine

pkg/cache/cache_test.go:146–166  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

144}
145
146func TestFileCache_missingFileIsFine(t *testing.T) {
147 t.Parallel()
148 dir := t.TempDir()
149 path := filepath.Join(dir, "nested", "cache.json")
150
151 c, err := New(Config{Enabled: true, Path: path})
152 require.NoError(t, err)
153
154 _, ok := c.Lookup("anything")
155 assert.False(t, ok)
156
157 c.Store("hello", "world")
158
159 got, ok := c.Lookup("hello")
160 assert.True(t, ok)
161 assert.Equal(t, "world", got)
162
163 // And the directory should have been created.
164 _, err = os.Stat(path)
165 assert.NoError(t, err)
166}
167
168func TestFileCache_corruptFile(t *testing.T) {
169 t.Parallel()

Callers

nothing calls this directly

Calls 3

NewFunction · 0.70
LookupMethod · 0.45
StoreMethod · 0.45

Tested by

no test coverage detected