Skip to content

Commit f218ca0

Browse files
Matt PryorEmilienM
authored andcommitted
Add requests test for new field
1 parent 0e644e4 commit f218ca0

2 files changed

Lines changed: 56 additions & 0 deletions

File tree

openstack/compute/v2/extensions/bootfromvolume/testing/fixtures.go

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,3 +308,53 @@ var NewVolumeTypeRequest = bootfromvolume.CreateOptsExt{
308308
},
309309
},
310310
}
311+
312+
const ExpectedImageAndExistingVolumeWithTagRequest = `
313+
{
314+
"server": {
315+
"name": "createdserver",
316+
"imageRef": "asdfasdfasdf",
317+
"flavorRef": "performance1-1",
318+
"block_device_mapping_v2":[
319+
{
320+
"boot_index": 0,
321+
"delete_on_termination": true,
322+
"destination_type":"local",
323+
"source_type":"image",
324+
"uuid":"asdfasdfasdf"
325+
},
326+
{
327+
"boot_index": -1,
328+
"delete_on_termination": true,
329+
"destination_type":"volume",
330+
"source_type":"volume",
331+
"tag": "volume-tag",
332+
"uuid":"123456",
333+
"volume_size": 1
334+
}
335+
]
336+
}
337+
}
338+
`
339+
340+
var ImageAndExistingVolumeWithTagRequest = bootfromvolume.CreateOptsExt{
341+
CreateOptsBuilder: BaseCreateOptsWithImageRef,
342+
BlockDevice: []bootfromvolume.BlockDevice{
343+
{
344+
BootIndex: 0,
345+
DeleteOnTermination: true,
346+
DestinationType: bootfromvolume.DestinationLocal,
347+
SourceType: bootfromvolume.SourceImage,
348+
UUID: "asdfasdfasdf",
349+
},
350+
{
351+
BootIndex: -1,
352+
DeleteOnTermination: true,
353+
DestinationType: bootfromvolume.DestinationVolume,
354+
SourceType: bootfromvolume.SourceVolume,
355+
Tag: "volume-tag",
356+
UUID: "123456",
357+
VolumeSize: 1,
358+
},
359+
},
360+
}

openstack/compute/v2/extensions/bootfromvolume/testing/requests_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,9 @@ func TestBootFromNewVolumeType(t *testing.T) {
4747
th.AssertNoErr(t, err)
4848
th.CheckJSONEquals(t, ExpectedNewVolumeTypeRequest, actual)
4949
}
50+
51+
func TestAttachExistingVolumeWithTag(t *testing.T) {
52+
actual, err := ImageAndExistingVolumeWithTagRequest.ToServerCreateMap()
53+
th.AssertNoErr(t, err)
54+
th.CheckJSONEquals(t, ExpectedImageAndExistingVolumeWithTagRequest, actual)
55+
}

0 commit comments

Comments
 (0)