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

Function TestValidateDockerImage

pkg/workflow/validation_test.go:91–130  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

89}
90
91func TestValidateDockerImage(t *testing.T) {
92 // Skip if docker is not available
93 if _, err := exec.LookPath("docker"); err != nil {
94 t.Skip("docker not available, skipping test")
95 }
96 // Also check if Docker daemon is running (not just if binary exists)
97 if !isDockerDaemonRunning() {
98 t.Skip("docker daemon not running, skipping test")
99 }
100
101 tests := []struct {
102 name string
103 image string
104 expectError bool
105 }{
106 {
107 name: "valid image - alpine",
108 image: "alpine:latest",
109 expectError: false,
110 },
111 {
112 name: "invalid image",
113 image: "nonexistent-image-12345:nonexistent",
114 expectError: true,
115 },
116 }
117
118 for _, tt := range tests {
119 t.Run(tt.name, func(t *testing.T) {
120 err := validateDockerImage(tt.image, false, false)
121
122 if tt.expectError && err == nil {
123 t.Error("expected error but got none")
124 }
125 if !tt.expectError && err != nil {
126 t.Errorf("unexpected error: %v", err)
127 }
128 })
129 }
130}
131
132func TestExtractNpxPackages(t *testing.T) {
133 tests := []struct {

Callers

nothing calls this directly

Calls 5

isDockerDaemonRunningFunction · 0.70
validateDockerImageFunction · 0.70
RunMethod · 0.45
ErrorMethod · 0.45
ErrorfMethod · 0.45

Tested by

no test coverage detected