MCPcopy Index your code
hub / github.com/databus23/helm-diff / TestLocalCmdDetailedExitCode

Function TestLocalCmdDetailedExitCode

cmd/local_test.go:147–186  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

145}
146
147func TestLocalCmdDetailedExitCode(t *testing.T) {
148 manifest1 := `---
149apiVersion: v1
150kind: ConfigMap
151metadata:
152 name: test-config
153 namespace: default
154data:
155 key: value1
156`
157 manifest2 := `---
158apiVersion: v1
159kind: ConfigMap
160metadata:
161 name: test-config
162 namespace: default
163data:
164 key: value2
165`
166 setupFakeHelmDual(t, manifest1, manifest2)
167
168 chart1 := t.TempDir()
169 chart2 := t.TempDir()
170
171 cmd := localCmd()
172 cmd.SetArgs([]string{chart1, chart2, "--detailed-exitcode"})
173
174 err := cmd.Execute()
175 if err == nil {
176 t.Fatal("Expected error with exit code 2 but got nil")
177 }
178
179 var diffErr Error
180 if !errors.As(err, &diffErr) {
181 t.Fatalf("Expected Error type but got %T: %v", err, err)
182 }
183 if diffErr.Code != 2 {
184 t.Errorf("Expected exit code 2 but got %d", diffErr.Code)
185 }
186}
187
188func TestLocalCmdDetailedExitCodeNoChanges(t *testing.T) {
189 manifestYAML := `---

Callers

nothing calls this directly

Calls 2

setupFakeHelmDualFunction · 0.85
localCmdFunction · 0.85

Tested by

no test coverage detected