Skip to content

Commit

Permalink
Recover from panic in SkipIfProviderIsNotHealthy
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonyunicorn committed Jan 10, 2025
1 parent db43391 commit 0b4935e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ var errAlreadyInProgress = regexp.MustCompile(`removal of container .* is alread
// This is a function designed to be used in your test, when Docker is not mandatory for CI/CD.
// In this way tests that depend on Testcontainers won't run if the provider is provisioned correctly.
func SkipIfProviderIsNotHealthy(t *testing.T) {
defer func() {
if r := recover(); r != nil {
t.Skipf("Recovered from panic. Docker is not running. TestContainers can't perform is work without it")
}
}()

t.Helper()
ctx := context.Background()
provider, err := ProviderDocker.GetProvider()
Expand Down

0 comments on commit 0b4935e

Please sign in to comment.