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

Function TestContainerPinCRUD

pkg/workflow/action_cache_container_pin_test.go:16–44  ·  view source on GitHub ↗

TestContainerPinCRUD verifies the Get/Set/Delete lifecycle for container pins.

(t *testing.T)

Source from the content-addressed store, hash-verified

14
15// TestContainerPinCRUD verifies the Get/Set/Delete lifecycle for container pins.
16func TestContainerPinCRUD(t *testing.T) {
17 cache := NewActionCache(t.TempDir())
18
19 // Initially no pin.
20 _, ok := cache.GetContainerPin("node:lts-alpine")
21 assert.False(t, ok, "no pin expected before Set")
22
23 // Set a pin.
24 cache.SetContainerPin("node:lts-alpine", "sha256:abc123", "node:lts-alpine@sha256:abc123")
25 pin, ok := cache.GetContainerPin("node:lts-alpine")
26 require.True(t, ok, "pin should exist after Set")
27 assert.Equal(t, "node:lts-alpine", pin.Image, "Image field")
28 assert.Equal(t, "sha256:abc123", pin.Digest, "Digest field")
29 assert.Equal(t, "node:lts-alpine@sha256:abc123", pin.PinnedImage, "PinnedImage field")
30
31 // Overwrite with updated pin.
32 cache.SetContainerPin("node:lts-alpine", "sha256:updated", "node:lts-alpine@sha256:updated")
33 pin, ok = cache.GetContainerPin("node:lts-alpine")
34 require.True(t, ok, "pin should exist after update")
35 assert.Equal(t, "sha256:updated", pin.Digest, "updated Digest")
36
37 // Delete the pin.
38 cache.DeleteContainerPin("node:lts-alpine")
39 _, ok = cache.GetContainerPin("node:lts-alpine")
40 assert.False(t, ok, "pin should be gone after Delete")
41
42 // Deleting a non-existent pin is a no-op.
43 assert.NotPanics(t, func() { cache.DeleteContainerPin("nonexistent:latest") }, "delete non-existent should not panic")
44}
45
46// TestContainerPinSaveLoad verifies that container pins survive a JSON round-trip.
47func TestContainerPinSaveLoad(t *testing.T) {

Callers

nothing calls this directly

Calls 4

GetContainerPinMethod · 0.95
SetContainerPinMethod · 0.95
DeleteContainerPinMethod · 0.95
NewActionCacheFunction · 0.85

Tested by

no test coverage detected