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

Function TestSnapshotDateIsFresh

pkg/modelsdev/snapshot_test.go:51–66  ·  view source on GitHub ↗

TestSnapshotDateIsFresh fails when the embedded snapshot is older than maxAge. It is the freshness gate that reminds maintainers to refresh the snapshot when the scheduled refresh workflow stops working. It is opt-in (gated on CHECK_MODELS_SNAPSHOT_FRESHNESS) and skipped by default. A snapshot ages

(t *testing.T)

Source from the content-addressed store, hash-verified

49// freshness mechanism is the weekly update-models workflow; this assertion is
50// a backstop the maintainer repo can opt into.
51func TestSnapshotDateIsFresh(t *testing.T) {
52 t.Parallel()
53
54 if os.Getenv("CHECK_MODELS_SNAPSHOT_FRESHNESS") == "" {
55 t.Skip("set CHECK_MODELS_SNAPSHOT_FRESHNESS=1 to enforce snapshot freshness")
56 }
57
58 const maxAge = 90 * 24 * time.Hour
59
60 date := SnapshotDate()
61 require.False(t, date.IsZero(), "snapshot_date.txt must contain a valid RFC3339 date")
62
63 age := time.Since(date)
64 assert.Less(t, age, maxAge,
65 "embedded models.dev snapshot is %s old; refresh it with `go generate ./pkg/modelsdev/...`", age)
66}
67
68// TestColdCacheFallsBackToSnapshot verifies the new behaviour: when the cache
69// is cold and the network is unreachable, a known-provider lookup resolves

Callers

nothing calls this directly

Calls 2

SnapshotDateFunction · 0.85
IsZeroMethod · 0.45

Tested by

no test coverage detected