Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ linters:
desc: use stdlib slices package
- pkg: gopkg.in/yaml.v2
desc: compose-go uses yaml.v3
- pkg: github.com/stretchr/testify/assert
desc: Use "gotest.tools/v3/assert" instead
- pkg: github.com/stretchr/testify/require
desc: Use "gotest.tools/v3/assert" instead
- pkg: github.com/stretchr/testify/suite
desc: Do not use
forbidigo:
analyze-types: true
forbid:
Expand Down
43 changes: 20 additions & 23 deletions cmd/compose/options_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ import (

"github.com/compose-spec/compose-go/v2/types"
"github.com/docker/cli/cli/streams"
"github.com/stretchr/testify/require"
"go.uber.org/mock/gomock"
"gotest.tools/v3/assert"

"github.com/docker/compose/v5/pkg/mocks"
)
Expand Down Expand Up @@ -56,15 +56,14 @@ func TestApplyPlatforms_InferFromRuntime(t *testing.T) {

t.Run("SinglePlatform", func(t *testing.T) {
project := makeProject()
require.NoError(t, applyPlatforms(project, true))
require.EqualValues(t, []string{"alice/32"}, project.Services["test"].Build.Platforms)
assert.NilError(t, applyPlatforms(project, true))
assert.DeepEqual(t, types.StringList{"alice/32"}, project.Services["test"].Build.Platforms)
})

t.Run("MultiPlatform", func(t *testing.T) {
project := makeProject()
require.NoError(t, applyPlatforms(project, false))
require.EqualValues(t, []string{"linux/amd64", "linux/arm64", "alice/32"},
project.Services["test"].Build.Platforms)
assert.NilError(t, applyPlatforms(project, false))
assert.DeepEqual(t, types.StringList{"linux/amd64", "linux/arm64", "alice/32"}, project.Services["test"].Build.Platforms)
})
}

Expand Down Expand Up @@ -92,15 +91,14 @@ func TestApplyPlatforms_DockerDefaultPlatform(t *testing.T) {

t.Run("SinglePlatform", func(t *testing.T) {
project := makeProject()
require.NoError(t, applyPlatforms(project, true))
require.EqualValues(t, []string{"linux/amd64"}, project.Services["test"].Build.Platforms)
assert.NilError(t, applyPlatforms(project, true))
assert.DeepEqual(t, types.StringList{"linux/amd64"}, project.Services["test"].Build.Platforms)
})

t.Run("MultiPlatform", func(t *testing.T) {
project := makeProject()
require.NoError(t, applyPlatforms(project, false))
require.EqualValues(t, []string{"linux/amd64", "linux/arm64"},
project.Services["test"].Build.Platforms)
assert.NilError(t, applyPlatforms(project, false))
assert.DeepEqual(t, types.StringList{"linux/amd64", "linux/arm64"}, project.Services["test"].Build.Platforms)
})
}

Expand Down Expand Up @@ -128,13 +126,13 @@ func TestApplyPlatforms_UnsupportedPlatform(t *testing.T) {

t.Run("SinglePlatform", func(t *testing.T) {
project := makeProject()
require.EqualError(t, applyPlatforms(project, true),
assert.Error(t, applyPlatforms(project, true),
`service "test" build.platforms does not support value set by DOCKER_DEFAULT_PLATFORM: commodore/64`)
})

t.Run("MultiPlatform", func(t *testing.T) {
project := makeProject()
require.EqualError(t, applyPlatforms(project, false),
assert.Error(t, applyPlatforms(project, false),
`service "test" build.platforms does not support value set by DOCKER_DEFAULT_PLATFORM: commodore/64`)
})
}
Expand Down Expand Up @@ -179,7 +177,7 @@ func TestIsRemoteConfig(t *testing.T) {
},
}
got := isRemoteConfig(cli, opts)
require.Equal(t, tt.want, got)
assert.Equal(t, tt.want, got)
})
}
}
Expand All @@ -206,7 +204,7 @@ func TestDisplayLocationRemoteStack(t *testing.T) {
displayLocationRemoteStack(cli, project, options)

output := buf.String()
require.Equal(t, output, fmt.Sprintf("Your compose stack %q is stored in %q\n", "oci://registry.example.com/stack:latest", "/tmp/test"))
assert.Equal(t, output, fmt.Sprintf("Your compose stack %q is stored in %q\n", "oci://registry.example.com/stack:latest", "/tmp/test"))
}

func TestDisplayInterpolationVariables(t *testing.T) {
Expand All @@ -227,7 +225,7 @@ services:
- UNSET_VAR # optional without default
`
composePath := filepath.Join(tmpDir, "docker-compose.yml")
require.NoError(t, os.WriteFile(composePath, []byte(composeContent), 0o644))
assert.NilError(t, os.WriteFile(composePath, []byte(composeContent), 0o644))

buf := new(bytes.Buffer)
cli := mocks.NewMockCli(ctrl)
Expand All @@ -244,8 +242,8 @@ services:

// Extract variables from the model
info, noVariables, err := extractInterpolationVariablesFromModel(t.Context(), cli, projectOptions, []string{})
require.NoError(t, err)
require.False(t, noVariables)
assert.NilError(t, err)
assert.Assert(t, noVariables == false)

// Display the variables
displayInterpolationVariables(cli.Out(), info)
Expand All @@ -267,7 +265,7 @@ services:
actualOutput := buf.String()

// Compare normalized strings
require.Equal(t,
assert.Equal(t,
normalizeSpaces(expected),
normalizeSpaces(actualOutput),
"\nExpected:\n%s\nGot:\n%s", expected, actualOutput)
Expand Down Expand Up @@ -370,14 +368,13 @@ func TestConfirmRemoteIncludes(t *testing.T) {
err := confirmRemoteIncludes(cli, tt.opts, tt.assumeYes)

if tt.wantErr {
require.Error(t, err)
require.Equal(t, tt.errMessage, err.Error())
assert.Error(t, err, tt.errMessage)
} else {
require.NoError(t, err)
assert.NilError(t, err)
}

if tt.wantOutput != "" {
require.Equal(t, tt.wantOutput, buf.String())
assert.Equal(t, tt.wantOutput, buf.String())
}
buf.Reset()
})
Expand Down
15 changes: 7 additions & 8 deletions cmd/compose/top_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ import (
"strings"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gotest.tools/v3/assert"

"github.com/docker/compose/v5/pkg/api"
)
Expand Down Expand Up @@ -221,20 +220,20 @@ func TestRunTopCore(t *testing.T) {

t.Run(tc.name, func(t *testing.T) {
header, entries := collectTop([]api.ContainerProcSummary{summary})
assert.Equal(t, tc.header, header)
assert.Equal(t, tc.entries, entries)
assert.DeepEqual(t, tc.header, header)
assert.DeepEqual(t, tc.entries, entries)

var buf bytes.Buffer
err := topPrint(&buf, header, entries)

require.NoError(t, err)
assert.NilError(t, err)
assert.Equal(t, tc.output, buf.String())
})
}

t.Run("all", func(t *testing.T) {
header, entries := collectTop(all)
assert.Equal(t, topHeader{
assert.DeepEqual(t, topHeader{
"SERVICE": 0,
"#": 1,
"UID": 2,
Expand All @@ -247,7 +246,7 @@ func TestRunTopCore(t *testing.T) {
"GID": 9,
"CMD": 10,
}, header)
assert.Equal(t, []topEntries{
assert.DeepEqual(t, []topEntries{
{
"SERVICE": "simple",
"#": "1",
Expand Down Expand Up @@ -308,7 +307,7 @@ func TestRunTopCore(t *testing.T) {

var buf bytes.Buffer
err := topPrint(&buf, header, entries)
require.NoError(t, err)
assert.NilError(t, err)
assert.Equal(t, trim(`
SERVICE # UID PID PPID C STIME TTY TIME GID CMD
simple 1 root 1 1 0 12:00 ? 00:00:01 - /entrypoint
Expand Down
9 changes: 4 additions & 5 deletions cmd/compose/viz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ package compose
import (
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gotest.tools/v3/assert"
)

func TestPreferredIndentationStr(t *testing.T) {
Expand Down Expand Up @@ -84,10 +83,10 @@ func TestPreferredIndentationStr(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
got, err := preferredIndentationStr(tt.args.size, tt.args.useSpace)
if tt.wantErr {
require.Errorf(t, err, "preferredIndentationStr(%v, %v)", tt.args.size, tt.args.useSpace)
assert.ErrorContains(t, err, "invalid indentation size", "preferredIndentationStr(%v,%v)", tt.args.size, tt.args.useSpace)
} else {
require.NoError(t, err)
assert.Equalf(t, tt.want, got, "preferredIndentationStr(%v, %v)", tt.args.size, tt.args.useSpace)
assert.NilError(t, err)
assert.Equal(t, tt.want, got)
}
})
}
Expand Down
3 changes: 0 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ require (
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
github.com/spf13/cobra v1.10.2
github.com/spf13/pflag v1.0.10
github.com/stretchr/testify v1.11.1
github.com/tilt-dev/fsnotify v1.4.8-0.20220602155310-fff9c274a375
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.63.0
go.opentelemetry.io/otel v1.42.0
Comment on lines 43 to 48
Copy link

Copilot AI Mar 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

go.mod removes github.com/stretchr/testify (and related indirect deps), but go.sum is not updated in this PR. The repo's vendor-validate target runs go mod tidy and fails if go.sum differs, so please run make go-mod-tidy (or go mod tidy) and commit the resulting go.sum changes.

Copilot uses AI. Check for mistakes.
Expand Down Expand Up @@ -73,7 +72,6 @@ require (
github.com/containerd/ttrpc v1.2.7 // indirect
github.com/containerd/typeurl/v2 v2.2.3 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.7 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/docker/distribution v2.8.3+incompatible // indirect
github.com/docker/docker-credential-helpers v0.9.5 // indirect
github.com/docker/go-connections v0.6.0 // indirect
Expand Down Expand Up @@ -113,7 +111,6 @@ require (
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/planetscale/vtprotobuf v0.6.1-0.20240319094008-0393e58bdf10 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 // indirect
Expand Down
6 changes: 3 additions & 3 deletions internal/desktop/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"
"gotest.tools/v3/assert"
)

func TestClientPing(t *testing.T) {
Expand All @@ -41,8 +41,8 @@ func TestClientPing(t *testing.T) {
now := time.Now()

ret, err := client.Ping(t.Context())
require.NoError(t, err)
assert.NilError(t, err)

serverTime := time.Unix(0, ret.ServerTime)
require.True(t, now.Before(serverTime))
assert.Assert(t, now.Before(serverTime))
}
18 changes: 9 additions & 9 deletions internal/tracing/attributes_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"testing"

"github.com/compose-spec/compose-go/v2/types"
"github.com/stretchr/testify/require"
"gotest.tools/v3/assert"
)

func TestProjectHash(t *testing.T) {
Expand Down Expand Up @@ -53,15 +53,15 @@ func TestProjectHash(t *testing.T) {
}

hashA, ok := projectHash(projA)
require.True(t, ok)
require.NotEmpty(t, hashA)
assert.Assert(t, ok)
assert.Assert(t, hashA != "")
hashB, ok := projectHash(projB)
require.True(t, ok)
require.NotEmpty(t, hashB)
require.Equal(t, hashA, hashB)
assert.Assert(t, ok)
assert.Assert(t, hashB != "")
assert.Equal(t, hashA, hashB)

hashC, ok := projectHash(projC)
require.True(t, ok)
require.NotEmpty(t, hashC)
require.NotEqual(t, hashC, hashA)
assert.Assert(t, ok)
assert.Assert(t, hashC != "")
assert.Assert(t, hashC != hashA)
}
8 changes: 4 additions & 4 deletions internal/tracing/tracing_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (

"github.com/docker/cli/cli/command"
"github.com/docker/cli/cli/context/store"
"github.com/stretchr/testify/require"
"gotest.tools/v3/assert"

"github.com/docker/compose/v5/internal/tracing"
)
Expand Down Expand Up @@ -52,9 +52,9 @@ func TestExtractOtelFromContext(t *testing.T) {
},
Endpoints: make(map[string]any),
})
require.NoError(t, err)
assert.NilError(t, err)

cfg, err := tracing.ConfigFromDockerContext(st, "test")
require.NoError(t, err)
require.Equal(t, "localhost:1234", cfg.Endpoint)
assert.NilError(t, err)
assert.Equal(t, "localhost:1234", cfg.Endpoint)
}
15 changes: 7 additions & 8 deletions pkg/compose/dependencies_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ import (
"testing"

"github.com/compose-spec/compose-go/v2/types"
testify "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"

"github.com/docker/compose/v5/pkg/utils"
)
Expand Down Expand Up @@ -85,11 +84,11 @@ func TestTraversalWithMultipleParents(t *testing.T) {
svc <- service
return nil
})
require.NoError(t, err, "Error during iteration")
assert.NilError(t, err, "Error during iteration")
close(svc)
<-done

testify.Len(t, seen, 101)
assert.Check(t, is.Len(seen, 101))
for svc, count := range seen {
assert.Equal(t, 1, count, "Service: %s", svc)
}
Expand All @@ -101,8 +100,8 @@ func TestInDependencyUpCommandOrder(t *testing.T) {
order = append(order, service)
return nil
})
require.NoError(t, err, "Error during iteration")
require.Equal(t, []string{"test3", "test2", "test1"}, order)
assert.NilError(t, err, "Error during iteration")
assert.DeepEqual(t, []string{"test3", "test2", "test1"}, order)
}

func TestInDependencyReverseDownCommandOrder(t *testing.T) {
Expand All @@ -111,8 +110,8 @@ func TestInDependencyReverseDownCommandOrder(t *testing.T) {
order = append(order, service)
return nil
})
require.NoError(t, err, "Error during iteration")
require.Equal(t, []string{"test1", "test2", "test3"}, order)
assert.NilError(t, err, "Error during iteration")
assert.DeepEqual(t, []string{"test1", "test2", "test3"}, order)
}

func TestBuildGraph(t *testing.T) {
Expand Down
Loading
Loading