Jon Perritt | 654fb0e | 2014-10-23 20:54:14 -0500 | [diff] [blame] | 1 | package bootfromvolume |
Jon Perritt | d9a4bf7 | 2014-10-23 23:44:04 -0500 | [diff] [blame] | 2 | |
| 3 | import ( |
| 4 | "testing" |
| 5 | |
| 6 | "github.com/rackspace/gophercloud/openstack/compute/v2/servers" |
| 7 | th "github.com/rackspace/gophercloud/testhelper" |
| 8 | ) |
| 9 | |
| 10 | func 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 Perritt | 01686cd | 2014-10-24 14:10:16 -0500 | [diff] [blame] | 19 | BlockDevice: []BlockDevice{ |
| 20 | BlockDevice{ |
| 21 | UUID: "123456", |
| 22 | SourceType: Image, |
| 23 | DestinationType: "volume", |
| 24 | VolumeSize: 10, |
| 25 | }, |
Jon Perritt | d9a4bf7 | 2014-10-23 23:44:04 -0500 | [diff] [blame] | 26 | }, |
| 27 | } |
| 28 | |
| 29 | expected := ` |
| 30 | { |
| 31 | "server": { |
| 32 | "name": "createdserver", |
| 33 | "imageRef": "asdfasdfasdf", |
| 34 | "flavorRef": "performance1-1", |
jrperritt | 4267c94 | 2015-05-22 10:59:35 -0600 | [diff] [blame] | 35 | "flavorName": "", |
| 36 | "imageName": "", |
Jon Perritt | d9a4bf7 | 2014-10-23 23:44:04 -0500 | [diff] [blame] | 37 | "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 | } |