blob: 0b5352751b4c90727023fec3dd5abb59fba8f2ab [file] [log] [blame]
Jon Perritt8dd49db2014-10-24 12:39:07 -05001package bootfromvolume
Jon Perritt61710222014-10-24 13:01:31 -05002
3import (
4 "testing"
5
6 osBFV "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/bootfromvolume"
7 "github.com/rackspace/gophercloud/openstack/compute/v2/servers"
8 th "github.com/rackspace/gophercloud/testhelper"
9)
10
11func TestCreateOpts(t *testing.T) {
12 base := servers.CreateOpts{
13 Name: "createdserver",
14 ImageRef: "asdfasdfasdf",
15 FlavorRef: "performance1-1",
16 }
17
18 ext := osBFV.CreateOptsExt{
19 CreateOptsBuilder: base,
Jon Perritt01686cd2014-10-24 14:10:16 -050020 BlockDevice: []osBFV.BlockDevice{
21 osBFV.BlockDevice{
22 UUID: "123456",
23 SourceType: osBFV.Image,
24 DestinationType: "volume",
25 VolumeSize: 10,
26 },
Jon Perritt61710222014-10-24 13:01:31 -050027 },
28 }
29
30 expected := `
31 {
32 "server": {
33 "name": "createdserver",
34 "imageRef": "asdfasdfasdf",
35 "flavorRef": "performance1-1",
36 "block_device_mapping_v2":[
37 {
38 "uuid":"123456",
39 "source_type":"image",
40 "destination_type":"volume",
41 "boot_index": "0",
42 "delete_on_termination": "false",
43 "volume_size": "10"
44 }
45 ]
46 }
47 }
48 `
49 actual, err := ext.ToServerCreateMap()
50 th.AssertNoErr(t, err)
51 th.CheckJSONEquals(t, expected, actual)
52}