@@ -24,6 +24,7 @@ func Test_CreateServer(t *testing.T) {
2424 Cmd : "scw instance server create -h" ,
2525 Check : core .TestCheckCombine (
2626 core .TestCheckGolden (),
27+ core .TestCheckExitCode (0 ),
2728 ),
2829 }))
2930
@@ -39,43 +40,56 @@ func Test_CreateServer(t *testing.T) {
3940 func (t * testing.T , ctx * core.CheckFuncCtx ) {
4041 assert .Equal (t , "Ubuntu Bionic Beaver" , ctx .Result .(* instance.Server ).Image .Name )
4142 },
43+ core .TestCheckExitCode (0 ),
4244 ),
4345 AfterFunc : deleteServerAfterFunc ,
4446 }))
4547
4648 t .Run ("GP1-XS" , core .Test (& core.TestConfig {
4749 Commands : GetCommands (),
4850 Cmd : "scw instance server create type=GP1-XS image=ubuntu_bionic stopped" ,
49- Check : func (t * testing.T , ctx * core.CheckFuncCtx ) {
50- assert .Equal (t , "GP1-XS" , ctx .Result .(* instance.Server ).CommercialType )
51- },
51+ Check : core .TestCheckCombine (
52+ func (t * testing.T , ctx * core.CheckFuncCtx ) {
53+ assert .Equal (t , "GP1-XS" , ctx .Result .(* instance.Server ).CommercialType )
54+ },
55+ core .TestCheckExitCode (0 ),
56+ ),
5257 AfterFunc : deleteServerAfterFunc ,
5358 }))
5459
5560 t .Run ("With name" , core .Test (& core.TestConfig {
5661 Commands : GetCommands (),
5762 Cmd : "scw instance server create image=ubuntu_bionic name=yo stopped" ,
58- Check : func (t * testing.T , ctx * core.CheckFuncCtx ) {
59- assert .Equal (t , "yo" , ctx .Result .(* instance.Server ).Name )
60- },
63+ Check : core .TestCheckCombine (
64+ func (t * testing.T , ctx * core.CheckFuncCtx ) {
65+ assert .Equal (t , "yo" , ctx .Result .(* instance.Server ).Name )
66+ },
67+ core .TestCheckExitCode (0 ),
68+ ),
6169 AfterFunc : deleteServerAfterFunc ,
6270 }))
6371
6472 t .Run ("With start" , core .Test (& core.TestConfig {
6573 Commands : GetCommands (),
6674 Cmd : "scw instance server create image=ubuntu_bionic -w" ,
67- Check : func (t * testing.T , ctx * core.CheckFuncCtx ) {
68- assert .Equal (t , instance .ServerStateRunning , ctx .Result .(* instance.Server ).State )
69- },
75+ Check : core .TestCheckCombine (
76+ func (t * testing.T , ctx * core.CheckFuncCtx ) {
77+ assert .Equal (t , instance .ServerStateRunning , ctx .Result .(* instance.Server ).State )
78+ },
79+ core .TestCheckExitCode (0 ),
80+ ),
7081 AfterFunc : deleteServerAfterFunc ,
7182 }))
7283
7384 t .Run ("With bootscript" , core .Test (& core.TestConfig {
7485 Commands : GetCommands (),
7586 Cmd : "scw instance server create image=ubuntu_bionic bootscript-id=eb760e3c-30d8-49a3-b3ad-ad10c3aa440b stopped" ,
76- Check : func (t * testing.T , ctx * core.CheckFuncCtx ) {
77- assert .Equal (t , "eb760e3c-30d8-49a3-b3ad-ad10c3aa440b" , ctx .Result .(* instance.Server ).Bootscript .ID )
78- },
87+ Check : core .TestCheckCombine (
88+ func (t * testing.T , ctx * core.CheckFuncCtx ) {
89+ assert .Equal (t , "eb760e3c-30d8-49a3-b3ad-ad10c3aa440b" , ctx .Result .(* instance.Server ).Bootscript .ID )
90+ },
91+ core .TestCheckExitCode (0 ),
92+ ),
7993 AfterFunc : deleteServerAfterFunc ,
8094 }))
8195
@@ -86,6 +100,7 @@ func Test_CreateServer(t *testing.T) {
86100 func (t * testing.T , ctx * core.CheckFuncCtx ) {
87101 assert .Equal (t , "Ubuntu Bionic Beaver" , ctx .Result .(* instance.Server ).Image .Name )
88102 },
103+ core .TestCheckExitCode (0 ),
89104 ),
90105 AfterFunc : deleteServerAfterFunc ,
91106 }))
@@ -98,6 +113,7 @@ func Test_CreateServer(t *testing.T) {
98113 assert .Equal (t , "prod" , ctx .Result .(* instance.Server ).Tags [0 ])
99114 assert .Equal (t , "blue" , ctx .Result .(* instance.Server ).Tags [1 ])
100115 },
116+ core .TestCheckExitCode (0 ),
101117 ),
102118 AfterFunc : deleteServerAfterFunc ,
103119 }))
@@ -111,30 +127,39 @@ func Test_CreateServer(t *testing.T) {
111127 t .Run ("valid single local volume" , core .Test (& core.TestConfig {
112128 Commands : GetCommands (),
113129 Cmd : "scw instance server create image=ubuntu_bionic root-volume=local:20GB stopped" ,
114- Check : func (t * testing.T , ctx * core.CheckFuncCtx ) {
115- assert .Equal (t , 20 * scw .GB , ctx .Result .(* instance.Server ).Volumes ["0" ].Size )
116- },
130+ Check : core .TestCheckCombine (
131+ func (t * testing.T , ctx * core.CheckFuncCtx ) {
132+ assert .Equal (t , 20 * scw .GB , ctx .Result .(* instance.Server ).Volumes ["0" ].Size )
133+ },
134+ core .TestCheckExitCode (0 ),
135+ ),
117136 AfterFunc : deleteServerAfterFunc ,
118137 }))
119138
120139 t .Run ("valid double local volumes" , core .Test (& core.TestConfig {
121140 Commands : GetCommands (),
122141 Cmd : "scw instance server create image=ubuntu_bionic root-volume=local:10GB additional-volumes.0=l:10G stopped" ,
123- Check : func (t * testing.T , ctx * core.CheckFuncCtx ) {
124- assert .Equal (t , 10 * scw .GB , ctx .Result .(* instance.Server ).Volumes ["0" ].Size )
125- assert .Equal (t , 10 * scw .GB , ctx .Result .(* instance.Server ).Volumes ["1" ].Size )
126- },
142+ Check : core .TestCheckCombine (
143+ func (t * testing.T , ctx * core.CheckFuncCtx ) {
144+ assert .Equal (t , 10 * scw .GB , ctx .Result .(* instance.Server ).Volumes ["0" ].Size )
145+ assert .Equal (t , 10 * scw .GB , ctx .Result .(* instance.Server ).Volumes ["1" ].Size )
146+ },
147+ core .TestCheckExitCode (0 ),
148+ ),
127149 AfterFunc : deleteServerAfterFunc ,
128150 }))
129151
130152 t .Run ("valid additional block volumes" , core .Test (& core.TestConfig {
131153 Commands : GetCommands (),
132154 Cmd : "scw instance server create image=ubuntu_bionic additional-volumes.0=b:1G additional-volumes.1=b:5G additional-volumes.2=b:10G stopped" ,
133- Check : func (t * testing.T , ctx * core.CheckFuncCtx ) {
134- assert .Equal (t , 1 * scw .GB , ctx .Result .(* instance.Server ).Volumes ["1" ].Size )
135- assert .Equal (t , 5 * scw .GB , ctx .Result .(* instance.Server ).Volumes ["2" ].Size )
136- assert .Equal (t , 10 * scw .GB , ctx .Result .(* instance.Server ).Volumes ["3" ].Size )
137- },
155+ Check : core .TestCheckCombine (
156+ func (t * testing.T , ctx * core.CheckFuncCtx ) {
157+ assert .Equal (t , 1 * scw .GB , ctx .Result .(* instance.Server ).Volumes ["1" ].Size )
158+ assert .Equal (t , 5 * scw .GB , ctx .Result .(* instance.Server ).Volumes ["2" ].Size )
159+ assert .Equal (t , 10 * scw .GB , ctx .Result .(* instance.Server ).Volumes ["3" ].Size )
160+ },
161+ core .TestCheckExitCode (0 ),
162+ ),
138163 AfterFunc : deleteServerAfterFunc ,
139164 }))
140165
@@ -147,21 +172,27 @@ func Test_CreateServer(t *testing.T) {
147172 t .Run ("explicit new IP" , core .Test (& core.TestConfig {
148173 Commands : GetCommands (),
149174 Cmd : "scw instance server create image=ubuntu_bionic ip=new stopped" ,
150- Check : func (t * testing.T , ctx * core.CheckFuncCtx ) {
151- assert .NotEmpty (t , ctx .Result .(* instance.Server ).PublicIP .Address )
152- assert .Equal (t , false , ctx .Result .(* instance.Server ).PublicIP .Dynamic )
153- },
175+ Check : core .TestCheckCombine (
176+ func (t * testing.T , ctx * core.CheckFuncCtx ) {
177+ assert .NotEmpty (t , ctx .Result .(* instance.Server ).PublicIP .Address )
178+ assert .Equal (t , false , ctx .Result .(* instance.Server ).PublicIP .Dynamic )
179+ },
180+ core .TestCheckExitCode (0 ),
181+ ),
154182 AfterFunc : deleteServerAfterFunc ,
155183 }))
156184
157185 t .Run ("run with dynamic IP" , core .Test (& core.TestConfig {
158186 Commands : GetCommands (),
159187 Cmd : "scw instance server create image=ubuntu_bionic ip=dynamic -w" , // dynamic IP is created at runtime
160- Check : func (t * testing.T , ctx * core.CheckFuncCtx ) {
161- assert .NoError (t , ctx .Err )
162- assert .NotEmpty (t , ctx .Result .(* instance.Server ).PublicIP .Address )
163- assert .Equal (t , true , ctx .Result .(* instance.Server ).DynamicIPRequired )
164- },
188+ Check : core .TestCheckCombine (
189+ func (t * testing.T , ctx * core.CheckFuncCtx ) {
190+ assert .NoError (t , ctx .Err )
191+ assert .NotEmpty (t , ctx .Result .(* instance.Server ).PublicIP .Address )
192+ assert .Equal (t , true , ctx .Result .(* instance.Server ).DynamicIPRequired )
193+ },
194+ core .TestCheckExitCode (0 ),
195+ ),
165196 AfterFunc : deleteServerAfterFunc ,
166197 }))
167198
@@ -172,10 +203,13 @@ func Test_CreateServer(t *testing.T) {
172203 return nil
173204 },
174205 Cmd : "scw instance server create image=ubuntu_bionic ip={{ .MyIP.IP.Address }} stopped" ,
175- Check : func (t * testing.T , ctx * core.CheckFuncCtx ) {
176- assert .NotEmpty (t , ctx .Result .(* instance.Server ).PublicIP .Address )
177- assert .Equal (t , false , ctx .Result .(* instance.Server ).PublicIP .Dynamic )
178- },
206+ Check : core .TestCheckCombine (
207+ func (t * testing.T , ctx * core.CheckFuncCtx ) {
208+ assert .NotEmpty (t , ctx .Result .(* instance.Server ).PublicIP .Address )
209+ assert .Equal (t , false , ctx .Result .(* instance.Server ).PublicIP .Dynamic )
210+ },
211+ core .TestCheckExitCode (0 ),
212+ ),
179213 AfterFunc : deleteServerAfterFunc ,
180214 }))
181215
@@ -186,19 +220,25 @@ func Test_CreateServer(t *testing.T) {
186220 return nil
187221 },
188222 Cmd : "scw instance server create image=ubuntu_bionic ip={{ .MyIP.IP.ID }} stopped" ,
189- Check : func (t * testing.T , ctx * core.CheckFuncCtx ) {
190- assert .NotEmpty (t , ctx .Result .(* instance.Server ).PublicIP .Address )
191- assert .Equal (t , false , ctx .Result .(* instance.Server ).PublicIP .Dynamic )
192- },
223+ Check : core .TestCheckCombine (
224+ func (t * testing.T , ctx * core.CheckFuncCtx ) {
225+ assert .NotEmpty (t , ctx .Result .(* instance.Server ).PublicIP .Address )
226+ assert .Equal (t , false , ctx .Result .(* instance.Server ).PublicIP .Dynamic )
227+ },
228+ core .TestCheckExitCode (0 ),
229+ ),
193230 AfterFunc : deleteServerAfterFunc ,
194231 }))
195232
196233 t .Run ("with ipv6" , core .Test (& core.TestConfig {
197234 Commands : GetCommands (),
198235 Cmd : "scw instance server create image=ubuntu_bionic ipv6 -w" , // IPv6 is created at runtime
199- Check : func (t * testing.T , ctx * core.CheckFuncCtx ) {
200- assert .NotEmpty (t , ctx .Result .(* instance.Server ).IPv6 .Address )
201- },
236+ Check : core .TestCheckCombine (
237+ func (t * testing.T , ctx * core.CheckFuncCtx ) {
238+ assert .NotEmpty (t , ctx .Result .(* instance.Server ).IPv6 .Address )
239+ },
240+ core .TestCheckExitCode (0 ),
241+ ),
202242 AfterFunc : deleteServerAfterFunc ,
203243 }))
204244 })
0 commit comments