blob: 6446ed65b8b844cefbb4c491c39e2ad931537efc [file] [log] [blame]
Ash Wilson5b505492014-10-23 10:28:22 -04001package diskconfig
2
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 DiskConfig: Manual,
20 }
21
22 expected := `
23 {
24 "server": {
25 "name": "createdserver",
26 "imageRef": "asdfasdfasdf",
27 "flavorRef": "performance1-1",
28 "OS-DCF:diskConfig": "MANUAL"
29 }
30 }
31 `
32 th.CheckJSONEquals(t, expected, ext.ToServerCreateMap())
33}
34
35func TestRebuildOpts(t *testing.T) {
36 base := servers.RebuildOpts{
37 Name: "createdserver",
38 AdminPass: "swordfish",
39 ImageID: "asdfasdfasdf",
40 }
41
42 ext := RebuildOptsExt{
43 RebuildOptsBuilder: base,
44 DiskConfig: Auto,
45 }
46
47 actual, err := ext.ToServerRebuildMap()
48 th.AssertNoErr(t, err)
49
50 expected := `
51 {
52 "rebuild": {
53 "name": "createdserver",
54 "imageRef": "asdfasdfasdf",
55 "adminPass": "swordfish",
56 "OS-DCF:diskConfig": "AUTO"
57 }
58 }
59 `
60 th.CheckJSONEquals(t, expected, actual)
61}