MCPcopy Create free account
hub / github.com/github/gh-aw / TestContainerPinSaveLoad

Function TestContainerPinSaveLoad

pkg/workflow/action_cache_container_pin_test.go:47–75  ·  view source on GitHub ↗

TestContainerPinSaveLoad verifies that container pins survive a JSON round-trip.

(t *testing.T)

Source from the content-addressed store, hash-verified

45
46// TestContainerPinSaveLoad verifies that container pins survive a JSON round-trip.
47func TestContainerPinSaveLoad(t *testing.T) {
48 tmpDir := testutil.TempDir(t, "container-pin-*")
49
50 cache := NewActionCache(tmpDir)
51 cache.Set("actions/checkout", "v5", "sha1")
52 cache.SetContainerPin("node:lts-alpine", "sha256:abc123", "node:lts-alpine@sha256:abc123")
53 cache.SetContainerPin("alpine:latest", "sha256:def456", "alpine:latest@sha256:def456")
54
55 require.NoError(t, cache.Save(), "Save should succeed")
56
57 // Reload from disk.
58 cache2 := NewActionCache(tmpDir)
59 require.NoError(t, cache2.Load(), "Load should succeed")
60
61 // Action entry should be preserved.
62 sha, ok := cache2.Get("actions/checkout", "v5")
63 require.True(t, ok, "action entry should be loaded")
64 assert.Equal(t, "sha1", sha, "SHA should match")
65
66 // Container pins should be preserved.
67 pin, ok := cache2.GetContainerPin("node:lts-alpine")
68 require.True(t, ok, "node pin should be loaded")
69 assert.Equal(t, "sha256:abc123", pin.Digest, "node digest")
70 assert.Equal(t, "node:lts-alpine@sha256:abc123", pin.PinnedImage, "node pinned image")
71
72 pin, ok = cache2.GetContainerPin("alpine:latest")
73 require.True(t, ok, "alpine pin should be loaded")
74 assert.Equal(t, "sha256:def456", pin.Digest, "alpine digest")
75}
76
77// TestContainerPinBackwardCompatibility verifies that loading an existing
78// actions-lock.json without a container_pins section returns an empty map

Callers

nothing calls this directly

Calls 8

SetMethod · 0.95
SetContainerPinMethod · 0.95
SaveMethod · 0.95
LoadMethod · 0.95
GetMethod · 0.95
GetContainerPinMethod · 0.95
TempDirFunction · 0.92
NewActionCacheFunction · 0.85

Tested by

no test coverage detected