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

Function TestSetContainerPinEdgeCases

pkg/workflow/action_cache_test.go:293–344  ·  view source on GitHub ↗

TestSetContainerPinEdgeCases verifies SetContainerPin behaviour with edge case inputs.

(t *testing.T)

Source from the content-addressed store, hash-verified

291
292// TestSetContainerPinEdgeCases verifies SetContainerPin behaviour with edge case inputs.
293func TestSetContainerPinEdgeCases(t *testing.T) {
294 tests := []struct {
295 name string
296 image string
297 digest string
298 pinnedImage string
299 wantOK bool // whether GetContainerPin should find it
300 }{
301 {
302 name: "valid pin",
303 image: "node:lts-alpine",
304 digest: "sha256:abc123",
305 pinnedImage: "node:lts-alpine@sha256:abc123",
306 wantOK: true,
307 },
308 {
309 name: "empty digest stored as-is",
310 image: "myimage:tag",
311 digest: "",
312 pinnedImage: "myimage:tag@",
313 wantOK: true,
314 },
315 {
316 name: "empty pinned_image stored as-is",
317 image: "myimage:v1",
318 digest: "sha256:deadbeef",
319 pinnedImage: "",
320 wantOK: true,
321 },
322 }
323
324 for _, tt := range tests {
325 t.Run(tt.name, func(t *testing.T) {
326 tmpDir := testutil.TempDir(t, "test-*")
327 cache := NewActionCache(tmpDir)
328 cache.SetContainerPin(tt.image, tt.digest, tt.pinnedImage)
329
330 pin, ok := cache.GetContainerPin(tt.image)
331 if ok != tt.wantOK {
332 t.Errorf("GetContainerPin returned ok=%v, want %v", ok, tt.wantOK)
333 }
334 if ok {
335 if pin.Digest != tt.digest {
336 t.Errorf("Digest: got %q, want %q", pin.Digest, tt.digest)
337 }
338 if pin.PinnedImage != tt.pinnedImage {
339 t.Errorf("PinnedImage: got %q, want %q", pin.PinnedImage, tt.pinnedImage)
340 }
341 }
342 })
343 }
344}
345
346// TestActionCacheDeduplication tests that duplicate entries are removed
347func TestActionCacheDeduplication(t *testing.T) {

Callers

nothing calls this directly

Calls 6

SetContainerPinMethod · 0.95
GetContainerPinMethod · 0.95
TempDirFunction · 0.92
NewActionCacheFunction · 0.85
RunMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected