Jamie Hannaford | f0cd165 | 2014-11-04 10:54:11 +0100 | [diff] [blame] | 1 | package vips |
Jamie Hannaford | 2841a53 | 2014-11-04 11:05:42 +0100 | [diff] [blame^] | 2 | |
| 3 | import ( |
| 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 | |
| 11 | const ( |
| 12 | lbID = 12345 |
| 13 | vipID = 67890 |
| 14 | ) |
| 15 | |
| 16 | func 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).EachPage(func(page pagination.Page) (bool, error) { |
| 25 | count++ |
| 26 | actual, err := ExtractVIPs(page) |
| 27 | th.AssertNoErr(t, err) |
| 28 | |
| 29 | expected := []VIP{ |
| 30 | VIP{ID: 1000, Address: "206.10.10.210", Type: "PUBLIC"}, |
| 31 | } |
| 32 | |
| 33 | th.CheckDeepEquals(t, expected, actual) |
| 34 | |
| 35 | return true, nil |
| 36 | }) |
| 37 | |
| 38 | th.AssertNoErr(t, err) |
| 39 | th.AssertEquals(t, 1, count) |
| 40 | } |