@@ -22,13 +22,14 @@ import (
2222 "io"
2323 "os"
2424 "path/filepath"
25+ "slices"
2526 "strings"
2627 "testing"
2728
2829 "github.com/compose-spec/compose-go/v2/types"
2930 "github.com/docker/cli/cli/streams"
30- "github.com/stretchr/testify/require"
3131 "go.uber.org/mock/gomock"
32+ "gotest.tools/v3/assert"
3233
3334 "github.com/docker/compose/v5/pkg/mocks"
3435)
@@ -56,15 +57,14 @@ func TestApplyPlatforms_InferFromRuntime(t *testing.T) {
5657
5758 t .Run ("SinglePlatform" , func (t * testing.T ) {
5859 project := makeProject ()
59- require . NoError (t , applyPlatforms (project , true ))
60- require . EqualValues (t , []string {"alice/32" }, project .Services ["test" ].Build .Platforms )
60+ assert . NilError (t , applyPlatforms (project , true ))
61+ assert . Check (t , slices . Equal ( []string {"alice/32" }, project .Services ["test" ].Build .Platforms ) )
6162 })
6263
6364 t .Run ("MultiPlatform" , func (t * testing.T ) {
6465 project := makeProject ()
65- require .NoError (t , applyPlatforms (project , false ))
66- require .EqualValues (t , []string {"linux/amd64" , "linux/arm64" , "alice/32" },
67- project .Services ["test" ].Build .Platforms )
66+ assert .NilError (t , applyPlatforms (project , false ))
67+ assert .Check (t , slices .Equal ([]string {"linux/amd64" , "linux/arm64" , "alice/32" }, project .Services ["test" ].Build .Platforms ))
6868 })
6969}
7070
@@ -92,15 +92,14 @@ func TestApplyPlatforms_DockerDefaultPlatform(t *testing.T) {
9292
9393 t .Run ("SinglePlatform" , func (t * testing.T ) {
9494 project := makeProject ()
95- require . NoError (t , applyPlatforms (project , true ))
96- require . EqualValues (t , []string {"linux/amd64" }, project .Services ["test" ].Build .Platforms )
95+ assert . NilError (t , applyPlatforms (project , true ))
96+ assert . DeepEqual (t , []string {"linux/amd64" }, project .Services ["test" ].Build .Platforms )
9797 })
9898
9999 t .Run ("MultiPlatform" , func (t * testing.T ) {
100100 project := makeProject ()
101- require .NoError (t , applyPlatforms (project , false ))
102- require .EqualValues (t , []string {"linux/amd64" , "linux/arm64" },
103- project .Services ["test" ].Build .Platforms )
101+ assert .NilError (t , applyPlatforms (project , false ))
102+ assert .DeepEqual (t , []string {"linux/amd64" , "linux/arm64" }, project .Services ["test" ].Build .Platforms )
104103 })
105104}
106105
@@ -128,13 +127,13 @@ func TestApplyPlatforms_UnsupportedPlatform(t *testing.T) {
128127
129128 t .Run ("SinglePlatform" , func (t * testing.T ) {
130129 project := makeProject ()
131- require . EqualError (t , applyPlatforms (project , true ),
130+ assert . Error (t , applyPlatforms (project , true ),
132131 `service "test" build.platforms does not support value set by DOCKER_DEFAULT_PLATFORM: commodore/64` )
133132 })
134133
135134 t .Run ("MultiPlatform" , func (t * testing.T ) {
136135 project := makeProject ()
137- require . EqualError (t , applyPlatforms (project , false ),
136+ assert . Error (t , applyPlatforms (project , false ),
138137 `service "test" build.platforms does not support value set by DOCKER_DEFAULT_PLATFORM: commodore/64` )
139138 })
140139}
@@ -179,7 +178,7 @@ func TestIsRemoteConfig(t *testing.T) {
179178 },
180179 }
181180 got := isRemoteConfig (cli , opts )
182- require .Equal (t , tt .want , got )
181+ assert .Equal (t , tt .want , got )
183182 })
184183 }
185184}
@@ -206,7 +205,7 @@ func TestDisplayLocationRemoteStack(t *testing.T) {
206205 displayLocationRemoteStack (cli , project , options )
207206
208207 output := buf .String ()
209- require .Equal (t , output , fmt .Sprintf ("Your compose stack %q is stored in %q\n " , "oci://registry.example.com/stack:latest" , "/tmp/test" ))
208+ assert .Equal (t , output , fmt .Sprintf ("Your compose stack %q is stored in %q\n " , "oci://registry.example.com/stack:latest" , "/tmp/test" ))
210209}
211210
212211func TestDisplayInterpolationVariables (t * testing.T ) {
@@ -227,7 +226,7 @@ services:
227226 - UNSET_VAR # optional without default
228227`
229228 composePath := filepath .Join (tmpDir , "docker-compose.yml" )
230- require . NoError (t , os .WriteFile (composePath , []byte (composeContent ), 0o644 ))
229+ assert . NilError (t , os .WriteFile (composePath , []byte (composeContent ), 0o644 ))
231230
232231 buf := new (bytes.Buffer )
233232 cli := mocks .NewMockCli (ctrl )
@@ -244,8 +243,8 @@ services:
244243
245244 // Extract variables from the model
246245 info , noVariables , err := extractInterpolationVariablesFromModel (t .Context (), cli , projectOptions , []string {})
247- require . NoError (t , err )
248- require . False (t , noVariables )
246+ assert . NilError (t , err )
247+ assert . Assert (t , noVariables == false )
249248
250249 // Display the variables
251250 displayInterpolationVariables (cli .Out (), info )
@@ -267,7 +266,7 @@ services:
267266 actualOutput := buf .String ()
268267
269268 // Compare normalized strings
270- require .Equal (t ,
269+ assert .Equal (t ,
271270 normalizeSpaces (expected ),
272271 normalizeSpaces (actualOutput ),
273272 "\n Expected:\n %s\n Got:\n %s" , expected , actualOutput )
@@ -370,14 +369,13 @@ func TestConfirmRemoteIncludes(t *testing.T) {
370369 err := confirmRemoteIncludes (cli , tt .opts , tt .assumeYes )
371370
372371 if tt .wantErr {
373- require .Error (t , err )
374- require .Equal (t , tt .errMessage , err .Error ())
372+ assert .Error (t , err , tt .errMessage )
375373 } else {
376- require . NoError (t , err )
374+ assert . NilError (t , err )
377375 }
378376
379377 if tt .wantOutput != "" {
380- require .Equal (t , tt .wantOutput , buf .String ())
378+ assert .Equal (t , tt .wantOutput , buf .String ())
381379 }
382380 buf .Reset ()
383381 })
0 commit comments