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