File: requests_test.go

package info (click to toggle)
golang-github-rackspace-gophercloud 1.0.0%2Bgit20160603.920.934dbf8-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,936 kB
  • ctags: 6,116
  • sloc: sh: 16; makefile: 4
file content (59 lines) | stat: -rw-r--r-- 1,158 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package servers

import (
	"testing"

	"github.com/rackspace/gophercloud/openstack/compute/v2/extensions/diskconfig"
	th "github.com/rackspace/gophercloud/testhelper"
)

func TestCreateOpts(t *testing.T) {
	opts := CreateOpts{
		Name:       "createdserver",
		ImageRef:   "image-id",
		FlavorRef:  "flavor-id",
		KeyPair:    "mykey",
		DiskConfig: diskconfig.Manual,
	}

	expected := `
	{
		"server": {
			"name": "createdserver",
			"imageRef": "image-id",
			"flavorRef": "flavor-id",
			"flavorName": "",
			"imageName": "",
			"key_name": "mykey",
			"OS-DCF:diskConfig": "MANUAL"
		}
	}
	`
	actual, err := opts.ToServerCreateMap()
	th.AssertNoErr(t, err)
	th.CheckJSONEquals(t, expected, actual)
}

func TestRebuildOpts(t *testing.T) {
	opts := RebuildOpts{
		Name:       "rebuiltserver",
		AdminPass:  "swordfish",
		ImageID:    "asdfasdfasdf",
		DiskConfig: diskconfig.Auto,
	}

	actual, err := opts.ToServerRebuildMap()
	th.AssertNoErr(t, err)

	expected := `
	{
		"rebuild": {
			"name": "rebuiltserver",
			"imageRef": "asdfasdfasdf",
			"adminPass": "swordfish",
			"OS-DCF:diskConfig": "AUTO"
		}
	}
	`
	th.CheckJSONEquals(t, expected, actual)
}