blob: 05096704b8265c45f5290b3b7bdee91a4e525407 [file] [log] [blame]
Jamie Hannafordb6927c12014-11-03 10:31:26 +01001package nodes
Jamie Hannaford3cfa00a2014-11-03 11:16:35 +01002
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
11const (
12 lbID = 12345
13 nodeID = 67890
14)
15
16func TestList(t *testing.T) {
17 th.SetupHTTP()
18 defer th.TeardownHTTP()
19
20 mockListResponse(t, lbID)
21
22 count := 0
23
24 err := List(client.ServiceClient(), lbID, nil).EachPage(func(page pagination.Page) (bool, error) {
25 count++
26 actual, err := ExtractNodes(page)
27 th.AssertNoErr(t, err)
28
29 expected := []Node{
30 Node{
31 ID: 410,
32 Address: "10.1.1.1",
33 Port: 80,
34 Condition: ENABLED,
35 Status: ONLINE,
36 Weight: 3,
37 Type: PRIMARY,
38 },
39 Node{
40 ID: 411,
41 Address: "10.1.1.2",
42 Port: 80,
43 Condition: ENABLED,
44 Status: ONLINE,
45 Weight: 8,
46 Type: SECONDARY,
47 },
48 }
49
50 th.CheckDeepEquals(t, expected, actual)
51
52 return true, nil
53 })
54
55 th.AssertNoErr(t, err)
56 th.AssertEquals(t, 1, count)
57}