blob: 794f0c8018ad1e7ecc8378fd11e5ad5248b16592 [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,
20 BlockDevice: osBFV.BlockDevice{
21 UUID: "123456",
22 SourceType: "image",
23 DestinationType: "volume",
24 VolumeSize: 10,
25 },
26 }
27
28 expected := `
29 {
30 "server": {
31 "name": "createdserver",
32 "imageRef": "asdfasdfasdf",
33 "flavorRef": "performance1-1",
34 "block_device_mapping_v2":[
35 {
36 "uuid":"123456",
37 "source_type":"image",
38 "destination_type":"volume",
39 "boot_index": "0",
40 "delete_on_termination": "false",
41 "volume_size": "10"
42 }
43 ]
44 }
45 }
46 `
47 actual, err := ext.ToServerCreateMap()
48 th.AssertNoErr(t, err)
49 th.CheckJSONEquals(t, expected, actual)
50}