Skip to content

Commit f034931

Browse files
committed
dockerUtils: use stdlib for testing
Only a single test was using testify for trivial asserts; use stdlib to reduce (indirect) dependencies. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
1 parent 82a33f5 commit f034931

3 files changed

Lines changed: 15 additions & 19 deletions

File tree

dockerUtils/dockerUtils_test.go

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import (
1616
"time"
1717

1818
"github.com/moby/moby/client"
19-
"github.com/stretchr/testify/assert"
2019
)
2120

2221
func TestGetContainer(t *testing.T) {
@@ -108,27 +107,37 @@ func TestListVolumesAt(t *testing.T) {
108107
volName := "testvolume"
109108
ctx := context.Background()
110109
_, err = docker.cli.VolumeCreate(ctx, client.VolumeCreateOptions{Name: volName, Driver: "local"})
111-
assert.NoError(t, err, "should be able to create a volume")
110+
if err != nil {
111+
t.Fatalf("should be able to create a volume: %v", err)
112+
}
112113

113114
// Clean up after test
114115
defer func() {
115116
_, err := docker.cli.VolumeRemove(ctx, volName, client.VolumeRemoveOptions{Force: true})
116-
assert.NoError(t, err, "should be able to remove the volume")
117+
if err != nil {
118+
t.Fatalf("should be able to remove the volume: %v", err)
119+
}
117120
}()
118121

119122
// Test the function
120123
mountPoint := filepath.Join("/var/lib/docker/volumes/", volName, "_data")
121124
volumes, err := docker.ListVolumesAt(mountPoint)
122-
assert.NoError(t, err, "should not have an error listing volumes")
123-
assert.True(t, len(volumes) > 0, "should find at least one volume")
125+
if err != nil {
126+
t.Fatalf("should not have an error listing volumes: %v", err)
127+
}
128+
if len(volumes) == 0 {
129+
t.Fatalf("should have at least one volume")
130+
}
124131
found := false
125132
for _, vol := range volumes {
126133
if vol.Name == volName && vol.Mountpoint == mountPoint {
127134
found = true
128135
break
129136
}
130137
}
131-
assert.True(t, found, "should find the test volume in the filtered list")
138+
if !found {
139+
t.Fatalf("should have found volume %s in %s", volName, mountPoint)
140+
}
132141
}
133142

134143
func TestDockerConnectDelay(t *testing.T) {

dockerUtils/go.mod

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ go 1.24
55
require (
66
github.com/moby/moby/api v1.54.2
77
github.com/moby/moby/client v0.4.1
8-
github.com/stretchr/testify v1.10.0
98
)
109

1110
require (
1211
github.com/Microsoft/go-winio v0.6.2 // indirect
1312
github.com/containerd/errdefs v1.0.0 // indirect
1413
github.com/containerd/errdefs/pkg v0.3.0 // indirect
15-
github.com/davecgh/go-spew v1.1.1 // indirect
1614
github.com/distribution/reference v0.6.0 // indirect
1715
github.com/docker/go-connections v0.7.0 // indirect
1816
github.com/docker/go-units v0.5.0 // indirect
@@ -22,12 +20,10 @@ require (
2220
github.com/moby/docker-image-spec v1.3.1 // indirect
2321
github.com/opencontainers/go-digest v1.0.0 // indirect
2422
github.com/opencontainers/image-spec v1.1.1 // indirect
25-
github.com/pmezard/go-difflib v1.0.0 // indirect
2623
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
2724
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.60.0 // indirect
2825
go.opentelemetry.io/otel v1.35.0 // indirect
2926
go.opentelemetry.io/otel/metric v1.35.0 // indirect
3027
go.opentelemetry.io/otel/trace v1.35.0 // indirect
3128
golang.org/x/sys v0.33.0 // indirect
32-
gopkg.in/yaml.v3 v3.0.1 // indirect
3329
)

dockerUtils/go.sum

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
2323
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
2424
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
2525
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
26-
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
27-
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
28-
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
29-
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
3026
github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3Nl2EsFP0=
3127
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
3228
github.com/moby/moby/api v1.54.2 h1:wiat9QAhnDQjA7wk1kh/TqHz2I1uUA7M7t9SAl/JNXg=
@@ -39,8 +35,6 @@ github.com/opencontainers/image-spec v1.1.1 h1:y0fUlFfIZhPF1W537XOLg0/fcx6zcHCJw
3935
github.com/opencontainers/image-spec v1.1.1/go.mod h1:qpqAh3Dmcf36wStyyWU+kCeDgrGnAve2nCC8+7h8Q0M=
4036
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
4137
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
42-
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
43-
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
4438
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
4539
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
4640
go.opentelemetry.io/auto/sdk v1.1.0 h1:cH53jehLUN6UFLY71z+NDOiNJqDdPRaXzTel0sJySYA=
@@ -59,9 +53,6 @@ go.opentelemetry.io/otel/trace v1.35.0 h1:dPpEfJu1sDIqruz7BHFG3c7528f6ddfSWfFDVt
5953
go.opentelemetry.io/otel/trace v1.35.0/go.mod h1:WUk7DtFp1Aw2MkvqGdwiXYDZZNvA/1J8o6xRXLrIkyc=
6054
golang.org/x/sys v0.33.0 h1:q3i8TbbEz+JRD9ywIRlyRAQbM0qF7hu24q3teo2hbuw=
6155
golang.org/x/sys v0.33.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
62-
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
63-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
64-
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
6556
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
6657
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
6758
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=

0 commit comments

Comments
 (0)