Skip to content

Commit 09dd613

Browse files
chore: recover from panic in SkipIfProviderIsNotHealthy test helper function (#2939)
* Recover from panic in SkipIfProviderIsNotHealthy * Fix typo Co-authored-by: Manuel de la Peña <[email protected]> * chore: test helper enhancements * Move t.Helper before defer * Include value of r in skip statement * Fix more typos --------- Co-authored-by: Manuel de la Peña <[email protected]>
1 parent 37ca2b4 commit 09dd613

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

testing.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,20 @@ var errAlreadyInProgress = regexp.MustCompile(`removal of container .* is alread
2121
// In this way tests that depend on Testcontainers won't run if the provider is provisioned correctly.
2222
func SkipIfProviderIsNotHealthy(t *testing.T) {
2323
t.Helper()
24+
defer func() {
25+
if r := recover(); r != nil {
26+
t.Skipf("Recovered from panic: %v. Docker is not running. Testcontainers can't perform is work without it", r)
27+
}
28+
}()
29+
2430
ctx := context.Background()
2531
provider, err := ProviderDocker.GetProvider()
2632
if err != nil {
27-
t.Skipf("Docker is not running. TestContainers can't perform is work without it: %s", err)
33+
t.Skipf("Docker is not running. Testcontainers can't perform is work without it: %s", err)
2834
}
2935
err = provider.Health(ctx)
3036
if err != nil {
31-
t.Skipf("Docker is not running. TestContainers can't perform is work without it: %s", err)
37+
t.Skipf("Docker is not running. Testcontainers can't perform is work without it: %s", err)
3238
}
3339
}
3440

0 commit comments

Comments
 (0)