Skip to content

Commit

Permalink
Use k6 return code to check test result
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Chacin <pablochacin@gmail.com>
  • Loading branch information
pablochacin committed Oct 5, 2023
1 parent 904a382 commit de11382
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion modules/k6/examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package k6_test

import (
"context"
"fmt"
"path/filepath"

"github.com/testcontainers/testcontainers-go/modules/k6"
Expand All @@ -11,7 +12,7 @@ func ExampleRunContainer() {
// runK6Container {
ctx := context.Background()

absPath, err := filepath.Abs("./scripts/test.js")
absPath, err := filepath.Abs("./scripts/pass.js")
if err != nil {
panic(err)
}
Expand All @@ -26,5 +27,14 @@ func ExampleRunContainer() {
panic(err)
}
}()

// assert the result of the test
state, err := container.State(ctx)
if err != nil {
panic(err)
}
if state.ExitCode != 0 {
panic(fmt.Errorf("test failed with exit code %d", state.ExitCode))
}
// }
}

0 comments on commit de11382

Please sign in to comment.