Jon Perritt | 8dd49db | 2014-10-24 12:39:07 -0500 | [diff] [blame] | 1 | package bootfromvolume |
Jon Perritt | 6171022 | 2014-10-24 13:01:31 -0500 | [diff] [blame] | 2 | |
| 3 | import ( |
| 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 | |
| 11 | func 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, |
Jon Perritt | 01686cd | 2014-10-24 14:10:16 -0500 | [diff] [blame] | 20 | BlockDevice: []osBFV.BlockDevice{ |
| 21 | osBFV.BlockDevice{ |
| 22 | UUID: "123456", |
| 23 | SourceType: osBFV.Image, |
| 24 | DestinationType: "volume", |
| 25 | VolumeSize: 10, |
| 26 | }, |
Jon Perritt | 6171022 | 2014-10-24 13:01:31 -0500 | [diff] [blame] | 27 | }, |
| 28 | } |
| 29 | |
| 30 | expected := ` |
| 31 | { |
| 32 | "server": { |
| 33 | "name": "createdserver", |
| 34 | "imageRef": "asdfasdfasdf", |
| 35 | "flavorRef": "performance1-1", |
| 36 | "block_device_mapping_v2":[ |
| 37 | { |
| 38 | "uuid":"123456", |
| 39 | "source_type":"image", |
| 40 | "destination_type":"volume", |
| 41 | "boot_index": "0", |
| 42 | "delete_on_termination": "false", |
| 43 | "volume_size": "10" |
| 44 | } |
| 45 | ] |
| 46 | } |
| 47 | } |
| 48 | ` |
| 49 | actual, err := ext.ToServerCreateMap() |
| 50 | th.AssertNoErr(t, err) |
| 51 | th.CheckJSONEquals(t, expected, actual) |
| 52 | } |