Skip to content

Commit

Permalink
Add requests test for new field
Browse files Browse the repository at this point in the history
  • Loading branch information
mkjpryor committed Sep 14, 2023
1 parent 3b67302 commit 4710541
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
50 changes: 50 additions & 0 deletions openstack/compute/v2/extensions/bootfromvolume/testing/fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -308,3 +308,53 @@ var NewVolumeTypeRequest = bootfromvolume.CreateOptsExt{
},
},
}

const ExpectedImageAndExistingVolumeWithTagRequest = `
{
"server": {
"name": "createdserver",
"imageRef": "asdfasdfasdf",
"flavorRef": "performance1-1",
"block_device_mapping_v2":[
{
"boot_index": 0,
"delete_on_termination": true,
"destination_type":"local",
"source_type":"image",
"uuid":"asdfasdfasdf"
},
{
"boot_index": -1,
"delete_on_termination": true,
"destination_type":"volume",
"source_type":"volume",
"tag": "volume-tag",
"uuid":"123456",
"volume_size": 1
}
]
}
}
`

var ImageAndExistingVolumeWithTagRequest = bootfromvolume.CreateOptsExt{
CreateOptsBuilder: BaseCreateOptsWithImageRef,
BlockDevice: []bootfromvolume.BlockDevice{
{
BootIndex: 0,
DeleteOnTermination: true,
DestinationType: bootfromvolume.DestinationLocal,
SourceType: bootfromvolume.SourceImage,
UUID: "asdfasdfasdf",
},
{
BootIndex: -1,
DeleteOnTermination: true,
DestinationType: bootfromvolume.DestinationVolume,
SourceType: bootfromvolume.SourceVolume,
Tag: "volume-tag",
UUID: "123456",
VolumeSize: 1,
},
},
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,9 @@ func TestBootFromNewVolumeType(t *testing.T) {
th.AssertNoErr(t, err)
th.CheckJSONEquals(t, ExpectedNewVolumeTypeRequest, actual)
}

func TestAttachExistingVolumeWithTag(t *testing.T) {
actual, err := ImageAndExistingVolumeWithTagRequest.ToServerCreateMap()
th.AssertNoErr(t, err)
th.CheckJSONEquals(t, ExpectedImageAndExistingVolumeWithTagRequest, actual)
}

0 comments on commit 4710541

Please sign in to comment.