@@ -20,15 +20,13 @@ func setYAMLRunnerSeams(t *testing.T) {
2020 oldHealth := checkHealthFn
2121 oldWaits := checkWaitsFn
2222 oldFiles := checkFilesExistFn
23- oldHealthCommands := checkHealthCommandsFn
2423 oldStandardRun := checkStandardRunFn
2524 oldRunnerOutput := checkRunnerOutputFn
2625 t .Cleanup (func () {
2726 loadContainerTestYAMLFn = oldLoad
2827 checkHealthFn = oldHealth
2928 checkWaitsFn = oldWaits
3029 checkFilesExistFn = oldFiles
31- checkHealthCommandsFn = oldHealthCommands
3230 checkStandardRunFn = oldStandardRun
3331 checkRunnerOutputFn = oldRunnerOutput
3432 })
@@ -157,13 +155,6 @@ func TestRunChecksFromYAMLValidationAndErrors(t *testing.T) {
157155 t .Fatalf ("expected standard run error" )
158156 }
159157
160- loadContainerTestYAMLFn = func (string ) (ContainerTestYAML , error ) {
161- return ContainerTestYAML {HealthCommands : []HealthCommandTestConfig {{Command : " " }}}, nil
162- }
163- if err := RunChecksFromYAML (ctx , "img" , "cfg.yaml" , nil ); err == nil || ! strings .Contains (err .Error (), "healthCommands[0].command" ) {
164- t .Fatalf ("expected health command validation error, got %v" , err )
165- }
166-
167158 loadContainerTestYAMLFn = func (string ) (ContainerTestYAML , error ) {
168159 return ContainerTestYAML {Runners : []RunnerConfig {{FilePath : " " }}}, nil
169160 }
@@ -205,14 +196,23 @@ func TestRunChecksFromYAMLValidationAndErrors(t *testing.T) {
205196 }
206197
207198 loadContainerTestYAMLFn = func (string ) (ContainerTestYAML , error ) {
208- return ContainerTestYAML {HealthCommands : []HealthCommandTestConfig {{Command : "mycommand " }}}, nil
199+ return ContainerTestYAML {HealthCommands : []HealthCommandTestConfig {{Command : " " }}}, nil
209200 }
210- checkFilesExistFn = CheckFilesExist
211- checkHealthCommandsFn = func (context. Context , string , * ContainerConfig , [] HealthCommandTestConfig ) error {
212- return errors . New ( "health commands boom" )
201+ checkFilesExistFn = func (context. Context , string , [] string , * ContainerConfig ) error {
202+ t . Fatalf ( "did not expect file checks" )
203+ return nil
213204 }
214- if err := RunChecksFromYAML (ctx , "img" , "cfg.yaml" , nil ); err == nil {
215- t .Fatalf ("expected health commands error" )
205+ checkWaitsFn = func (context.Context , string , []HTTPTestConfig , []TCPTestConfig , * ContainerConfig ) error {
206+ t .Fatalf ("did not expect wait checks" )
207+ return nil
208+ }
209+ checkHealthFn = func (context.Context , string , * ContainerConfig ) error {
210+ t .Fatalf ("did not expect health check" )
211+ return nil
212+ }
213+ checkStandardRunFn = func (context.Context , string , * ContainerConfig ) error { return nil }
214+ if err := RunChecksFromYAML (ctx , "img" , "cfg.yaml" , nil ); err != nil {
215+ t .Fatalf ("expected healthCommands to be ignored, got %v" , err )
216216 }
217217}
218218
@@ -289,7 +289,6 @@ func TestRunChecksFromYAMLCallsAllCheckTypes(t *testing.T) {
289289 calledHealth := 0
290290 calledWaits := 0
291291 calledFiles := 0
292- calledHealthCommands := 0
293292 calledStandardRun := 0
294293
295294 loadContainerTestYAMLFn = func (string ) (ContainerTestYAML , error ) {
@@ -300,7 +299,6 @@ func TestRunChecksFromYAMLCallsAllCheckTypes(t *testing.T) {
300299 TimeoutSeconds : 1 ,
301300 FilePath : "/etc/hosts" ,
302301 }},
303- HealthCommands : []HealthCommandTestConfig {{Command : "mycommand" , ExpectedExitCode : intPtr (7 ), ExpectedContent : "ok" , MatchContent : true }},
304302 }, nil
305303 }
306304
@@ -329,11 +327,6 @@ func TestRunChecksFromYAMLCallsAllCheckTypes(t *testing.T) {
329327 callOrder = append (callOrder , "files" )
330328 return nil
331329 }
332- checkHealthCommandsFn = func (context.Context , string , * ContainerConfig , []HealthCommandTestConfig ) error {
333- calledHealthCommands ++
334- callOrder = append (callOrder , "healthCommands" )
335- return nil
336- }
337330 checkStandardRunFn = func (context.Context , string , * ContainerConfig ) error {
338331 calledStandardRun ++
339332 return nil
@@ -343,13 +336,13 @@ func TestRunChecksFromYAMLCallsAllCheckTypes(t *testing.T) {
343336 t .Fatalf ("unexpected run error: %v" , err )
344337 }
345338
346- if calledHealth != 1 || calledWaits != 1 || calledFiles != 1 || calledHealthCommands != 1 || calledStandardRun != 1 {
347- t .Fatalf ("expected all checks once, got health=%d waits=%d files=%d healthCommands=%d standardRun=%d" , calledHealth , calledWaits , calledFiles , calledHealthCommands , calledStandardRun )
339+ if calledHealth != 1 || calledWaits != 1 || calledFiles != 1 || calledStandardRun != 1 {
340+ t .Fatalf ("expected all checks once, got health=%d waits=%d files=%d standardRun=%d" , calledHealth , calledWaits , calledFiles , calledStandardRun )
348341 }
349342
350- // New order: health → files → waits → healthCommands
351- if len (callOrder ) < 4 || callOrder [0 ] != "health" || callOrder [1 ] != "files" || callOrder [2 ] != "waits" || callOrder [ 3 ] != "healthCommands " {
352- t .Fatalf ("expected health→files→waits→healthCommands call order, got %v" , callOrder )
343+ // New order: health → files → waits
344+ if len (callOrder ) < 3 || callOrder [0 ] != "health" || callOrder [1 ] != "files" || callOrder [2 ] != "waits" {
345+ t .Fatalf ("expected health→files→waits call order, got %v" , callOrder )
353346 }
354347}
355348
0 commit comments