Skip to content

Commit 10ff7ad

Browse files
aauschclaude
authored andcommitted
fix: skip host network tests on colima
SkipIfDockerDesktop only checked for Docker Desktop by OS name, but colima also runs Docker inside a Linux VM where host networking doesn't work. Detect colima via DOCKER_HOST containing "colima" and skip early. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent b474e6f commit 10ff7ad

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

testing.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import (
44
"context"
55
"fmt"
66
"io"
7+
"os"
78
"regexp"
9+
"strings"
810
"testing"
911

1012
"github.com/containerd/errdefs"
@@ -40,9 +42,18 @@ func SkipIfProviderIsNotHealthy(t *testing.T) {
4042
}
4143

4244
// SkipIfDockerDesktop is a utility function capable of skipping tests
43-
// if tests are run using Docker Desktop.
45+
// if tests are run using Docker Desktop or another VM-based Docker
46+
// environment (e.g. colima) where host network access is not available.
4447
func SkipIfDockerDesktop(t *testing.T, ctx context.Context) {
4548
t.Helper()
49+
50+
// Colima runs Docker inside a Linux VM, so host networking doesn't work
51+
// the same way as native Docker on Linux. Detect it via DOCKER_HOST which
52+
// typically contains the colima socket path.
53+
if strings.Contains(os.Getenv("DOCKER_HOST"), "colima") {
54+
t.Skip("Skipping test that requires host network access when running in colima")
55+
}
56+
4657
cli, err := NewDockerClientWithOpts(ctx)
4758
require.NoErrorf(t, err, "failed to create docker client: %s", err)
4859

0 commit comments

Comments
 (0)