@@ -20,11 +20,12 @@ import (
20
20
"context"
21
21
"testing"
22
22
23
+ "github.com/docker/docker/api/types/filters"
24
+
23
25
"github.com/docker/compose-cli/api/compose"
24
26
"github.com/docker/compose-cli/local/mocks"
25
27
26
28
apitypes "github.com/docker/docker/api/types"
27
- "github.com/docker/docker/api/types/filters"
28
29
"github.com/golang/mock/gomock"
29
30
"gotest.tools/v3/assert"
30
31
)
@@ -35,23 +36,22 @@ func TestDown(t *testing.T) {
35
36
api := mocks .NewMockAPIClient (mockCtrl )
36
37
tested .apiClient = api
37
38
38
- ctx := context .Background ()
39
- api .EXPECT ().ContainerList (ctx , projectFilterListOpt ()).Return (
40
- []apitypes.Container {testContainer ("service1" , "123" ), testContainer ("service1" , "456" ), testContainer ("service2" , "789" ), testContainer ("service_orphan" , "321" )}, nil )
39
+ api .EXPECT ().ContainerList (gomock .Any (), projectFilterListOpt ()).Return (
40
+ []apitypes.Container {testContainer ("service1" , "123" ), testContainer ("service2" , "456" ), testContainer ("service2" , "789" ), testContainer ("service_orphan" , "321" )}, nil )
41
41
42
- api .EXPECT ().ContainerStop (ctx , "123" , nil ).Return (nil )
43
- api .EXPECT ().ContainerStop (ctx , "456" , nil ).Return (nil )
44
- api .EXPECT ().ContainerStop (ctx , "789" , nil ).Return (nil )
42
+ api .EXPECT ().ContainerStop (gomock . Any () , "123" , nil ).Return (nil )
43
+ api .EXPECT ().ContainerStop (gomock . Any () , "456" , nil ).Return (nil )
44
+ api .EXPECT ().ContainerStop (gomock . Any () , "789" , nil ).Return (nil )
45
45
46
- api .EXPECT ().ContainerRemove (ctx , "123" , apitypes.ContainerRemoveOptions {Force : true }).Return (nil )
47
- api .EXPECT ().ContainerRemove (ctx , "456" , apitypes.ContainerRemoveOptions {Force : true }).Return (nil )
48
- api .EXPECT ().ContainerRemove (ctx , "789" , apitypes.ContainerRemoveOptions {Force : true }).Return (nil )
46
+ api .EXPECT ().ContainerRemove (gomock . Any () , "123" , apitypes.ContainerRemoveOptions {Force : true }).Return (nil )
47
+ api .EXPECT ().ContainerRemove (gomock . Any () , "456" , apitypes.ContainerRemoveOptions {Force : true }).Return (nil )
48
+ api .EXPECT ().ContainerRemove (gomock . Any () , "789" , apitypes.ContainerRemoveOptions {Force : true }).Return (nil )
49
49
50
- api .EXPECT ().NetworkList (ctx , apitypes.NetworkListOptions {Filters : filters .NewArgs (projectFilter (testProject ))}).Return ([]apitypes.NetworkResource {{ID : "myProject_default" }}, nil )
50
+ api .EXPECT ().NetworkList (gomock . Any () , apitypes.NetworkListOptions {Filters : filters .NewArgs (projectFilter (testProject ))}).Return ([]apitypes.NetworkResource {{ID : "myProject_default" }}, nil )
51
51
52
- api .EXPECT ().NetworkRemove (ctx , "myProject_default" ).Return (nil )
52
+ api .EXPECT ().NetworkRemove (gomock . Any () , "myProject_default" ).Return (nil )
53
53
54
- err := tested .Down (ctx , testProject , compose.DownOptions {})
54
+ err := tested .Down (context . Background () , testProject , compose.DownOptions {})
55
55
assert .NilError (t , err )
56
56
}
57
57
@@ -61,22 +61,21 @@ func TestDownRemoveOrphans(t *testing.T) {
61
61
api := mocks .NewMockAPIClient (mockCtrl )
62
62
tested .apiClient = api
63
63
64
- ctx := context .Background ()
65
- api .EXPECT ().ContainerList (ctx , projectFilterListOpt ()).Return (
64
+ api .EXPECT ().ContainerList (gomock .Any (), projectFilterListOpt ()).Return (
66
65
[]apitypes.Container {testContainer ("service1" , "123" ), testContainer ("service2" , "789" ), testContainer ("service_orphan" , "321" )}, nil )
67
66
68
- api .EXPECT ().ContainerStop (ctx , "123" , nil ).Return (nil )
69
- api .EXPECT ().ContainerStop (ctx , "789" , nil ).Return (nil )
70
- api .EXPECT ().ContainerStop (ctx , "321" , nil ).Return (nil )
67
+ api .EXPECT ().ContainerStop (gomock . Any () , "123" , nil ).Return (nil )
68
+ api .EXPECT ().ContainerStop (gomock . Any () , "789" , nil ).Return (nil )
69
+ api .EXPECT ().ContainerStop (gomock . Any () , "321" , nil ).Return (nil )
71
70
72
- api .EXPECT ().ContainerRemove (ctx , "123" , apitypes.ContainerRemoveOptions {Force : true }).Return (nil )
73
- api .EXPECT ().ContainerRemove (ctx , "789" , apitypes.ContainerRemoveOptions {Force : true }).Return (nil )
74
- api .EXPECT ().ContainerRemove (ctx , "321" , apitypes.ContainerRemoveOptions {Force : true }).Return (nil )
71
+ api .EXPECT ().ContainerRemove (gomock . Any () , "123" , apitypes.ContainerRemoveOptions {Force : true }).Return (nil )
72
+ api .EXPECT ().ContainerRemove (gomock . Any () , "789" , apitypes.ContainerRemoveOptions {Force : true }).Return (nil )
73
+ api .EXPECT ().ContainerRemove (gomock . Any () , "321" , apitypes.ContainerRemoveOptions {Force : true }).Return (nil )
75
74
76
- api .EXPECT ().NetworkList (ctx , apitypes.NetworkListOptions {Filters : filters .NewArgs (projectFilter (testProject ))}).Return ([]apitypes.NetworkResource {{ID : "myProject_default" }}, nil )
75
+ api .EXPECT ().NetworkList (gomock . Any () , apitypes.NetworkListOptions {Filters : filters .NewArgs (projectFilter (testProject ))}).Return ([]apitypes.NetworkResource {{ID : "myProject_default" }}, nil )
77
76
78
- api .EXPECT ().NetworkRemove (ctx , "myProject_default" ).Return (nil )
77
+ api .EXPECT ().NetworkRemove (gomock . Any () , "myProject_default" ).Return (nil )
79
78
80
- err := tested .Down (ctx , testProject , compose.DownOptions {RemoveOrphans : true })
79
+ err := tested .Down (context . Background () , testProject , compose.DownOptions {RemoveOrphans : true })
81
80
assert .NilError (t , err )
82
81
}
0 commit comments