blob: ac7058f39eea89ad1145df58efc75f6408f16d24 [file] [log] [blame]
Ash Wilsonae0ca652014-10-23 12:30:12 -04001package servers
2
3import (
4 "testing"
5
6 "github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig"
7 th "github.com/rackspace/gophercloud/testhelper"
8)
9
10func TestCreateOpts(t *testing.T) {
11 opts := CreateOpts{
12 Name: "createdserver",
13 ImageRef: "image-id",
14 FlavorRef: "flavor-id",
15 KeyPair: "mykey",
16 DiskConfig: diskconfig.Manual,
17 }
18
19 expected := `
20 {
21 "server": {
22 "name": "createdserver",
23 "imageRef": "image-id",
24 "flavorRef": "flavor-id",
25 "key_name": "mykey",
26 "OS-DCF:diskConfig": "MANUAL"
27 }
28 }
29 `
30 th.CheckJSONEquals(t, expected, opts.ToServerCreateMap())
31}
Ash Wilsond7814a32014-10-23 12:49:25 -040032
33func TestRebuildOpts(t *testing.T) {
34 opts := RebuildOpts{
35 Name: "rebuiltserver",
36 AdminPass: "swordfish",
37 ImageID: "asdfasdfasdf",
38 DiskConfig: diskconfig.Auto,
39 }
40
41 actual, err := opts.ToServerRebuildMap()
42 th.AssertNoErr(t, err)
43
44 expected := `
45 {
46 "rebuild": {
47 "name": "rebuiltserver",
48 "imageRef": "asdfasdfasdf",
49 "adminPass": "swordfish",
50 "OS-DCF:diskConfig": "AUTO"
51 }
52 }
53 `
54 th.CheckJSONEquals(t, expected, actual)
55}