blob: 5bf9137906c19d58171d55865bd0c2e90f5ed502 [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",
35 "block_device_mapping_v2":[
36 {
37 "uuid":"123456",
38 "source_type":"image",
39 "destination_type":"volume",
40 "boot_index": "0",
41 "delete_on_termination": "false",
42 "volume_size": "10"
43 }
44 ]
45 }
46 }
47 `
48 actual, err := ext.ToServerCreateMap()
49 th.AssertNoErr(t, err)
50 th.CheckJSONEquals(t, expected, actual)
51}