blob: 467f05ce9543f4c1869faea2a97d6a12f25a2649 [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,
Jon Perritt01686cd2014-10-24 14:10:16 -050019 BlockDevice: []BlockDevice{
20 BlockDevice{
21 UUID: "123456",
22 SourceType: Image,
23 DestinationType: "volume",
24 VolumeSize: 10,
25 },
Jon Perrittd9a4bf72014-10-23 23:44:04 -050026 },
27 }
28
29 expected := `
30 {
31 "server": {
32 "name": "createdserver",
33 "imageRef": "asdfasdfasdf",
34 "flavorRef": "performance1-1",
Jon Perrittad5f1cb2015-05-20 10:38:13 -060035 "flavorName": "",
36 "imageName": "",
Jon Perrittd9a4bf72014-10-23 23:44:04 -050037 "block_device_mapping_v2":[
38 {
39 "uuid":"123456",
40 "source_type":"image",
41 "destination_type":"volume",
42 "boot_index": "0",
43 "delete_on_termination": "false",
44 "volume_size": "10"
45 }
46 ]
47 }
48 }
49 `
50 actual, err := ext.ToServerCreateMap()
51 th.AssertNoErr(t, err)
52 th.CheckJSONEquals(t, expected, actual)
53}