Skip to content

Commit 962320f

Browse files
committed
extend unit tests
1 parent 1ff48ce commit 962320f

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

internal/cmd/beta/server/create/create_test.go

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,68 @@ func TestParseInput(t *testing.T) {
260260
model.BootVolumeSourceType = utils.Ptr("image")
261261
}),
262262
},
263+
{
264+
description: "invalid without image-id, boot-volume-source-id and type",
265+
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
266+
delete(flagValues, bootVolumeSourceIdFlag)
267+
delete(flagValues, bootVolumeSourceTypeFlag)
268+
delete(flagValues, imageIdFlag)
269+
}),
270+
isValid: false,
271+
},
272+
{
273+
description: "invalid with boot-volume-source-id and without type",
274+
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
275+
delete(flagValues, bootVolumeSourceTypeFlag)
276+
}),
277+
isValid: false,
278+
},
279+
{
280+
description: "invalid with boot-volume-source-type is image and without size",
281+
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
282+
delete(flagValues, bootVolumeSizeFlag)
283+
flagValues[bootVolumeSourceIdFlag] = testImageId
284+
flagValues[bootVolumeSourceTypeFlag] = "image"
285+
}),
286+
isValid: false,
287+
},
288+
{
289+
description: "valid with image-id",
290+
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
291+
delete(flagValues, bootVolumeSourceIdFlag)
292+
delete(flagValues, bootVolumeSourceTypeFlag)
293+
delete(flagValues, bootVolumeSizeFlag)
294+
}),
295+
isValid: true,
296+
expectedModel: fixtureInputModel(func(model *inputModel) {
297+
model.BootVolumeSourceId = nil
298+
model.BootVolumeSourceType = nil
299+
model.BootVolumeSize = nil
300+
}),
301+
},
302+
{
303+
description: "valid with boot-volume-source-id and type volume",
304+
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
305+
delete(flagValues, imageIdFlag)
306+
delete(flagValues, bootVolumeSizeFlag)
307+
308+
}),
309+
isValid: true,
310+
expectedModel: fixtureInputModel(func(model *inputModel) {
311+
model.ImageId = nil
312+
model.BootVolumeSize = nil
313+
}),
314+
},
315+
{
316+
description: "valid with boot-volume-source-id, type volume and size",
317+
flagValues: fixtureFlagValues(func(flagValues map[string]string) {
318+
delete(flagValues, imageIdFlag)
319+
}),
320+
isValid: true,
321+
expectedModel: fixtureInputModel(func(model *inputModel) {
322+
model.ImageId = nil
323+
}),
324+
},
263325
}
264326

265327
for _, tt := range tests {

0 commit comments

Comments
 (0)