File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package integration_test
22
33import (
4+ "context"
45 "testing"
56
67 "github.com/docker/docker/client"
78)
89
910var dockerClient * client.Client
11+ var dockerAvailable bool
1012
1113func TestMain (m * testing.M ) {
1214 var err error
1315 dockerClient , err = client .NewClientWithOpts (client .FromEnv , client .WithAPIVersionNegotiation ())
14- if err != nil {
15- panic (err )
16+ if err == nil {
17+ _ , err = dockerClient .Ping (context .Background ())
18+ dockerAvailable = err == nil
1619 }
1720 m .Run ()
1821}
22+
23+ func requireDocker (t * testing.T ) {
24+ t .Helper ()
25+ if ! dockerAvailable {
26+ t .Skip ("Docker is not available" )
27+ }
28+ }
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ const (
2222const containerName = "localstack-aws"
2323
2424func TestStartCommandSucceedsWithValidToken (t * testing.T ) {
25+ requireDocker (t )
2526 authToken := os .Getenv ("LOCALSTACK_AUTH_TOKEN" )
2627 require .NotEmpty (t , authToken , "LOCALSTACK_AUTH_TOKEN must be set to run this test" )
2728
@@ -43,6 +44,7 @@ func TestStartCommandSucceedsWithValidToken(t *testing.T) {
4344}
4445
4546func TestStartCommandTriggersLoginWithoutToken (t * testing.T ) {
47+ requireDocker (t )
4648 cleanup ()
4749 t .Cleanup (cleanup )
4850
@@ -80,6 +82,7 @@ func TestStartCommandTriggersLoginWithoutToken(t *testing.T) {
8082}
8183
8284func TestStartCommandSucceedsWithKeyringToken (t * testing.T ) {
85+ requireDocker (t )
8386 cleanup ()
8487 t .Cleanup (cleanup )
8588
@@ -105,6 +108,7 @@ func TestStartCommandSucceedsWithKeyringToken(t *testing.T) {
105108}
106109
107110func TestStartCommandFailsWithInvalidToken (t * testing.T ) {
111+ requireDocker (t )
108112 cleanup ()
109113 t .Cleanup (cleanup )
110114
You can’t perform that action at this time.
0 commit comments