blob: 07fec51b1b8f5ea1331d4ff83b843aa01618ad26 [file] [log] [blame]
Joe Topjianc9fb21b2015-02-22 05:55:48 +00001package servergroups
2
3import (
4 "testing"
5
6 "github.com/rackspace/gophercloud/pagination"
7 th "github.com/rackspace/gophercloud/testhelper"
8 "github.com/rackspace/gophercloud/testhelper/client"
9)
10
11func TestList(t *testing.T) {
12 th.SetupHTTP()
13 defer th.TeardownHTTP()
14 HandleListSuccessfully(t)
15
16 count := 0
17 err := List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
18 count++
19 actual, err := ExtractServerGroups(page)
20 th.AssertNoErr(t, err)
21 th.CheckDeepEquals(t, ExpectedServerGroupSlice, actual)
22
23 return true, nil
24 })
25 th.AssertNoErr(t, err)
26 th.CheckEquals(t, 1, count)
27}
28
29func TestCreate(t *testing.T) {
30 th.SetupHTTP()
31 defer th.TeardownHTTP()
32 HandleCreateSuccessfully(t)
33
34 actual, err := Create(client.ServiceClient(), CreateOpts{
35 Name: "test",
36 Policies: []string{"anti-affinity"},
37 }).Extract()
38 th.AssertNoErr(t, err)
39 th.CheckDeepEquals(t, &CreatedServerGroup, actual)
40}
41
42func TestGet(t *testing.T) {
43 th.SetupHTTP()
44 defer th.TeardownHTTP()
45 HandleGetSuccessfully(t)
46
47 actual, err := Get(client.ServiceClient(), "4d8c3732-a248-40ed-bebc-539a6ffd25c0").Extract()
48 th.AssertNoErr(t, err)
49 th.CheckDeepEquals(t, &FirstServerGroup, actual)
50}
51
52func TestDelete(t *testing.T) {
53 th.SetupHTTP()
54 defer th.TeardownHTTP()
55 HandleDeleteSuccessfully(t)
56
57 err := Delete(client.ServiceClient(), "616fb98f-46ca-475e-917e-2563e5a8cd19").ExtractErr()
58 th.AssertNoErr(t, err)
59}