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

Function TestColdCacheFallsBackToSnapshot

pkg/modelsdev/snapshot_test.go:71–85  ·  view source on GitHub ↗

TestColdCacheFallsBackToSnapshot verifies the new behaviour: when the cache is cold and the network is unreachable, a known-provider lookup resolves against the embedded snapshot instead of erroring out.

(t *testing.T)

Source from the content-addressed store, hash-verified

69// is cold and the network is unreachable, a known-provider lookup resolves
70// against the embedded snapshot instead of erroring out.
71func TestColdCacheFallsBackToSnapshot(t *testing.T) {
72 t.Parallel()
73
74 cacheFile := filepath.Join(t.TempDir(), "models_dev.json")
75 fetched, fetch := trackingFetcher()
76 store, err := NewStore(WithCache(cacheFile), WithFetcher(fetch))
77 require.NoError(t, err)
78
79 // gpt-4o is present in the embedded snapshot; the fetch fails, so the
80 // resolution must come from the snapshot.
81 m, err := store.GetModel(t.Context(), NewID("openai", "gpt-4o"))
82 require.NoError(t, err)
83 assert.True(t, *fetched, "a cold cache must still attempt a fetch first")
84 assert.NotEmpty(t, m.Name)
85}
86
87// TestSnapshotFallbackIsNotMemoized guards against pinning the embedded
88// fallback for the Store's lifetime: a transient fetch failure must degrade to

Callers

nothing calls this directly

Calls 7

GetModelMethod · 0.95
trackingFetcherFunction · 0.85
WithFetcherFunction · 0.85
NewIDFunction · 0.85
ContextMethod · 0.80
NewStoreFunction · 0.70
WithCacheFunction · 0.70

Tested by

no test coverage detected