Skip to content

Commit

Permalink
test: print builder logs on failure
Browse files Browse the repository at this point in the history
  • Loading branch information
jooola committed Nov 2, 2023
1 parent ac1ed06 commit 52532c1
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions builder/hcloud/builder_acc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,22 @@ func TestBuilderAcc_basic(t *testing.T) {
return nil
},
Template: testBuilderAccBasic,
Check: func(buildCommand *exec.Cmd, logfile string) error {
Check: func(buildCommand *exec.Cmd, logFile string) error {
if buildCommand.ProcessState != nil {
if buildCommand.ProcessState.ExitCode() != 0 {
return fmt.Errorf("Bad exit code. Logfile: %s", logfile)
if buildCommand.ProcessState.ExitCode() == 0 {
return nil
}

logs, err := os.ReadFile(logFile)
if err != nil {
return err
}
return fmt.Errorf("invalid exit code: %d\n%s",
buildCommand.ProcessState.ExitCode(),
logs,
)
}

return nil
},
}
Expand Down

0 comments on commit 52532c1

Please sign in to comment.