Ash Wilson | 61dcb02 | 2014-10-03 08:15:47 -0400 | [diff] [blame] | 1 | package extensions |
| 2 | |
| 3 | import ( |
Ash Wilson | 61dcb02 | 2014-10-03 08:15:47 -0400 | [diff] [blame] | 4 | "testing" |
| 5 | |
Jon Perritt | 27249f4 | 2016-02-18 10:35:59 -0600 | [diff] [blame^] | 6 | "github.com/gophercloud/gophercloud/pagination" |
| 7 | th "github.com/gophercloud/gophercloud/testhelper" |
| 8 | "github.com/gophercloud/gophercloud/testhelper/client" |
Ash Wilson | 61dcb02 | 2014-10-03 08:15:47 -0400 | [diff] [blame] | 9 | ) |
| 10 | |
Ash Wilson | 61dcb02 | 2014-10-03 08:15:47 -0400 | [diff] [blame] | 11 | func TestList(t *testing.T) { |
| 12 | th.SetupHTTP() |
| 13 | defer th.TeardownHTTP() |
Ash Wilson | ce942a8 | 2014-10-13 11:48:01 -0400 | [diff] [blame] | 14 | HandleListExtensionsSuccessfully(t) |
Ash Wilson | 61dcb02 | 2014-10-03 08:15:47 -0400 | [diff] [blame] | 15 | |
| 16 | count := 0 |
| 17 | |
Ash Wilson | ce942a8 | 2014-10-13 11:48:01 -0400 | [diff] [blame] | 18 | List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) { |
Ash Wilson | 61dcb02 | 2014-10-03 08:15:47 -0400 | [diff] [blame] | 19 | count++ |
| 20 | actual, err := ExtractExtensions(page) |
Ash Wilson | ce942a8 | 2014-10-13 11:48:01 -0400 | [diff] [blame] | 21 | th.AssertNoErr(t, err) |
| 22 | th.AssertDeepEquals(t, ExpectedExtensions, actual) |
Ash Wilson | 61dcb02 | 2014-10-03 08:15:47 -0400 | [diff] [blame] | 23 | |
| 24 | return true, nil |
| 25 | }) |
| 26 | |
Ash Wilson | ce942a8 | 2014-10-13 11:48:01 -0400 | [diff] [blame] | 27 | th.CheckEquals(t, 1, count) |
Ash Wilson | 61dcb02 | 2014-10-03 08:15:47 -0400 | [diff] [blame] | 28 | } |
| 29 | |
| 30 | func TestGet(t *testing.T) { |
| 31 | th.SetupHTTP() |
| 32 | defer th.TeardownHTTP() |
Ash Wilson | ce942a8 | 2014-10-13 11:48:01 -0400 | [diff] [blame] | 33 | HandleGetExtensionSuccessfully(t) |
Ash Wilson | 61dcb02 | 2014-10-03 08:15:47 -0400 | [diff] [blame] | 34 | |
Ash Wilson | ce942a8 | 2014-10-13 11:48:01 -0400 | [diff] [blame] | 35 | actual, err := Get(client.ServiceClient(), "agent").Extract() |
| 36 | th.AssertNoErr(t, err) |
| 37 | th.CheckDeepEquals(t, SingleExtension, actual) |
Ash Wilson | 61dcb02 | 2014-10-03 08:15:47 -0400 | [diff] [blame] | 38 | } |