blob: c5cb6ed6f07e16e6b1219a152bebf201246b5a48 [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",
Jon Perrittad5f1cb2015-05-20 10:38:13 -060036 "flavorName": "",
37 "imageName": "",
Jon Perritt61710222014-10-24 13:01:31 -050038 "block_device_mapping_v2":[
39 {
40 "uuid":"123456",
41 "source_type":"image",
42 "destination_type":"volume",
43 "boot_index": "0",
44 "delete_on_termination": "false",
45 "volume_size": "10"
46 }
47 ]
48 }
49 }
50 `
51 actual, err := ext.ToServerCreateMap()
52 th.AssertNoErr(t, err)
53 th.CheckJSONEquals(t, expected, actual)
54}