@@ -28,8 +28,7 @@ func TestCompletion(t *testing.T) {
28
28
nerdtest .Setup ()
29
29
30
30
testCase := & test.Case {
31
- Description : "Base completion" ,
32
- Require : test .Not (nerdtest .Docker ),
31
+ Require : test .Not (nerdtest .Docker ),
33
32
Setup : func (data test.Data , helpers test.Helpers ) {
34
33
helpers .Ensure ("pull" , testutil .AlpineImage )
35
34
helpers .Ensure ("network" , "create" , data .Identifier ())
@@ -43,37 +42,37 @@ func TestCompletion(t *testing.T) {
43
42
SubTests : []* test.Case {
44
43
{
45
44
Description : "--cgroup-manager" ,
46
- Command : test .RunCommand ("__complete" , "--cgroup-manager" , "" ),
45
+ Command : test .Command ("__complete" , "--cgroup-manager" , "" ),
47
46
Expected : test .Expects (0 , nil , test .Contains ("cgroupfs\n " )),
48
47
},
49
48
{
50
49
Description : "--snapshotter" ,
51
- Command : test .RunCommand ("__complete" , "--snapshotter" , "" ),
50
+ Command : test .Command ("__complete" , "--snapshotter" , "" ),
52
51
Expected : test .Expects (0 , nil , test .Contains ("native\n " )),
53
52
},
54
53
{
55
54
Description : "empty" ,
56
- Command : test .RunCommand ("__complete" , "" ),
55
+ Command : test .Command ("__complete" , "" ),
57
56
Expected : test .Expects (0 , nil , test .Contains ("run\t " )),
58
57
},
59
58
{
60
59
Description : "run -" ,
61
- Command : test .RunCommand ("__complete" , "run" , "-" ),
60
+ Command : test .Command ("__complete" , "run" , "-" ),
62
61
Expected : test .Expects (0 , nil , test .Contains ("--network\t " )),
63
62
},
64
63
{
65
64
Description : "run --n" ,
66
- Command : test .RunCommand ("__complete" , "run" , "--n" ),
65
+ Command : test .Command ("__complete" , "run" , "--n" ),
67
66
Expected : test .Expects (0 , nil , test .Contains ("--network\t " )),
68
67
},
69
68
{
70
69
Description : "run --ne" ,
71
- Command : test .RunCommand ("__complete" , "run" , "--ne" ),
70
+ Command : test .Command ("__complete" , "run" , "--ne" ),
72
71
Expected : test .Expects (0 , nil , test .Contains ("--network\t " )),
73
72
},
74
73
{
75
74
Description : "run --net" ,
76
- Command : test .RunCommand ("__complete" , "run" , "--net" , "" ),
75
+ Command : test .Command ("__complete" , "run" , "--net" , "" ),
77
76
Expected : func (data test.Data , helpers test.Helpers ) * test.Expected {
78
77
return & test.Expected {
79
78
Output : test .All (
@@ -85,7 +84,7 @@ func TestCompletion(t *testing.T) {
85
84
},
86
85
{
87
86
Description : "run -it --net" ,
88
- Command : test .RunCommand ("__complete" , "run" , "-it" , "--net" , "" ),
87
+ Command : test .Command ("__complete" , "run" , "-it" , "--net" , "" ),
89
88
Expected : func (data test.Data , helpers test.Helpers ) * test.Expected {
90
89
return & test.Expected {
91
90
Output : test .All (
@@ -97,7 +96,7 @@ func TestCompletion(t *testing.T) {
97
96
},
98
97
{
99
98
Description : "run -ti --rm --net" ,
100
- Command : test .RunCommand ("__complete" , "run" , "-it" , "--rm" , "--net" , "" ),
99
+ Command : test .Command ("__complete" , "run" , "-it" , "--rm" , "--net" , "" ),
101
100
Expected : func (data test.Data , helpers test.Helpers ) * test.Expected {
102
101
return & test.Expected {
103
102
Output : test .All (
@@ -109,12 +108,12 @@ func TestCompletion(t *testing.T) {
109
108
},
110
109
{
111
110
Description : "run --restart" ,
112
- Command : test .RunCommand ("__complete" , "run" , "--restart" , "" ),
111
+ Command : test .Command ("__complete" , "run" , "--restart" , "" ),
113
112
Expected : test .Expects (0 , nil , test .Contains ("always\n " )),
114
113
},
115
114
{
116
115
Description : "network --rm" ,
117
- Command : test .RunCommand ("__complete" , "network" , "rm" , "" ),
116
+ Command : test .Command ("__complete" , "network" , "rm" , "" ),
118
117
Expected : func (data test.Data , helpers test.Helpers ) * test.Expected {
119
118
return & test.Expected {
120
119
Output : test .All (
@@ -126,15 +125,15 @@ func TestCompletion(t *testing.T) {
126
125
},
127
126
{
128
127
Description : "run --cap-add" ,
129
- Command : test .RunCommand ("__complete" , "run" , "--cap-add" , "" ),
128
+ Command : test .Command ("__complete" , "run" , "--cap-add" , "" ),
130
129
Expected : test .Expects (0 , nil , test .All (
131
130
test .Contains ("sys_admin\n " ),
132
131
test .DoesNotContain ("CAP_SYS_ADMIN\n " ),
133
132
)),
134
133
},
135
134
{
136
135
Description : "volume inspect" ,
137
- Command : test .RunCommand ("__complete" , "volume" , "inspect" , "" ),
136
+ Command : test .Command ("__complete" , "volume" , "inspect" , "" ),
138
137
Expected : func (data test.Data , helpers test.Helpers ) * test.Expected {
139
138
return & test.Expected {
140
139
Output : test .Contains (data .Get ("identifier" ) + "\n " ),
@@ -143,7 +142,7 @@ func TestCompletion(t *testing.T) {
143
142
},
144
143
{
145
144
Description : "volume rm" ,
146
- Command : test .RunCommand ("__complete" , "volume" , "rm" , "" ),
145
+ Command : test .Command ("__complete" , "volume" , "rm" , "" ),
147
146
Expected : func (data test.Data , helpers test.Helpers ) * test.Expected {
148
147
return & test.Expected {
149
148
Output : test .Contains (data .Get ("identifier" ) + "\n " ),
@@ -152,52 +151,46 @@ func TestCompletion(t *testing.T) {
152
151
},
153
152
{
154
153
Description : "no namespace --cgroup-manager" ,
155
- Command : func (data test.Data , helpers test.Helpers ) test.Command {
156
- cmd := helpers .Command ()
157
- cmd .Clear ()
158
- cmd .WithBinary ("nerdctl" )
159
- cmd .WithArgs ("__complete" , "--cgroup-manager" , "" )
160
- return cmd
154
+ Command : func (data test.Data , helpers test.Helpers ) test.TestableCommand {
155
+ return helpers .Custom ("nerdctl" , "__complete" , "--cgroup-manager" , "" )
161
156
},
162
157
Expected : test .Expects (0 , nil , test .Contains ("cgroupfs\n " )),
163
158
},
164
159
{
165
160
Description : "no namespace empty" ,
166
- Command : func (data test.Data , helpers test.Helpers ) test.Command {
167
- return helpers .Command (). Clear (). WithBinary ( "nerdctl" ). WithArgs ( "__complete" , "" )
161
+ Command : func (data test.Data , helpers test.Helpers ) test.TestableCommand {
162
+ return helpers .Custom ( "nerdctl" , "__complete" , "" )
168
163
},
169
164
Expected : test .Expects (0 , nil , test .Contains ("run\t " )),
170
165
},
171
166
{
172
167
Description : "namespace space empty" ,
173
- Command : func (data test.Data , helpers test.Helpers ) test.Command {
168
+ Command : func (data test.Data , helpers test.Helpers ) test.TestableCommand {
174
169
// mind {"--namespace=nerdctl-test"} vs {"--namespace", "nerdctl-test"}
175
- return helpers .Command ().Clear ().WithBinary ("nerdctl" ).
176
- WithArgs ("__complete" , "--namespace" , testutil .Namespace , "" )
170
+ return helpers .Custom ("nerdctl" , "__complete" , "--namespace" , string (helpers .Read (nerdtest .Namespace )), "" )
177
171
},
178
172
Expected : test .Expects (0 , nil , test .Contains ("run\t " )),
179
173
},
180
174
{
181
175
Description : "run -i" ,
182
- Command : test .RunCommand ("__complete" , "run" , "-i" , "" ),
176
+ Command : test .Command ("__complete" , "run" , "-i" , "" ),
183
177
Expected : test .Expects (0 , nil , test .Contains (testutil .AlpineImage )),
184
178
},
185
179
{
186
180
Description : "run -it" ,
187
- Command : test .RunCommand ("__complete" , "run" , "-it" , "" ),
181
+ Command : test .Command ("__complete" , "run" , "-it" , "" ),
188
182
Expected : test .Expects (0 , nil , test .Contains (testutil .AlpineImage )),
189
183
},
190
184
{
191
185
Description : "run -it --rm" ,
192
- Command : test .RunCommand ("__complete" , "run" , "-it" , "--rm" , "" ),
186
+ Command : test .Command ("__complete" , "run" , "-it" , "--rm" , "" ),
193
187
Expected : test .Expects (0 , nil , test .Contains (testutil .AlpineImage )),
194
188
},
195
189
{
196
190
Description : "namespace run -i" ,
197
- Command : func (data test.Data , helpers test.Helpers ) test.Command {
191
+ Command : func (data test.Data , helpers test.Helpers ) test.TestableCommand {
198
192
// mind {"--namespace=nerdctl-test"} vs {"--namespace", "nerdctl-test"}
199
- return helpers .Command ().Clear ().WithBinary ("nerdctl" ).
200
- WithArgs ("__complete" , "--namespace" , testutil .Namespace , "run" , "-i" , "" )
193
+ return helpers .Custom ("nerdctl" , "__complete" , "--namespace" , string (helpers .Read (nerdtest .Namespace )), "run" , "-i" , "" )
201
194
},
202
195
Expected : test .Expects (0 , nil , test .Contains (testutil .AlpineImage + "\n " )),
203
196
},
0 commit comments