forked from testcontainers/testcontainers-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testing.go
22 lines (20 loc) · 769 Bytes
/
testing.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package testcontainers
import (
"context"
"testing"
)
// SkipIfProviderIsNotHealthy is a utility function capable of skipping tests
// if the provider is not healthy, or running at all.
// 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) {
ctx := context.Background()
provider, err := ProviderDocker.GetProvider()
if err != nil {
t.Skipf("Docker is not running. TestContainers can't perform is work without it: %s", err)
}
err = provider.Health(ctx)
if err != nil {
t.Skipf("Docker is not running. TestContainers can't perform is work without it: %s", err)
}
}