Ash Wilson | f4d6363 | 2014-10-09 14:54:06 -0400 | [diff] [blame] | 1 | package extensions |
| 2 | |
| 3 | import ( |
Ash Wilson | f4d6363 | 2014-10-09 14:54:06 -0400 | [diff] [blame] | 4 | "testing" |
| 5 | |
| 6 | common "github.com/rackspace/gophercloud/openstack/common/extensions" |
Ash Wilson | f4d6363 | 2014-10-09 14:54:06 -0400 | [diff] [blame] | 7 | "github.com/rackspace/gophercloud/pagination" |
| 8 | th "github.com/rackspace/gophercloud/testhelper" |
| 9 | fake "github.com/rackspace/gophercloud/testhelper/client" |
| 10 | ) |
| 11 | |
| 12 | func TestList(t *testing.T) { |
| 13 | th.SetupHTTP() |
| 14 | defer th.TeardownHTTP() |
Ash Wilson | 56d97a6 | 2014-10-13 12:07:47 -0400 | [diff] [blame] | 15 | common.HandleListExtensionsSuccessfully(t) |
Ash Wilson | f4d6363 | 2014-10-09 14:54:06 -0400 | [diff] [blame] | 16 | |
| 17 | count := 0 |
| 18 | |
| 19 | err := List(fake.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) { |
| 20 | count++ |
| 21 | actual, err := ExtractExtensions(page) |
| 22 | th.AssertNoErr(t, err) |
Ash Wilson | 56d97a6 | 2014-10-13 12:07:47 -0400 | [diff] [blame] | 23 | th.AssertDeepEquals(t, common.ExpectedExtensions, actual) |
Ash Wilson | f4d6363 | 2014-10-09 14:54:06 -0400 | [diff] [blame] | 24 | |
| 25 | return true, nil |
| 26 | }) |
| 27 | th.AssertNoErr(t, err) |
| 28 | th.CheckEquals(t, 1, count) |
| 29 | } |
| 30 | |
| 31 | func TestGet(t *testing.T) { |
| 32 | th.SetupHTTP() |
| 33 | defer th.TeardownHTTP() |
Ash Wilson | 56d97a6 | 2014-10-13 12:07:47 -0400 | [diff] [blame] | 34 | common.HandleGetExtensionSuccessfully(t) |
Ash Wilson | f4d6363 | 2014-10-09 14:54:06 -0400 | [diff] [blame] | 35 | |
Ash Wilson | 56d97a6 | 2014-10-13 12:07:47 -0400 | [diff] [blame] | 36 | actual, err := Get(fake.ServiceClient(), "agent").Extract() |
| 37 | th.AssertNoErr(t, err) |
| 38 | th.CheckDeepEquals(t, common.SingleExtension, actual) |
Ash Wilson | f4d6363 | 2014-10-09 14:54:06 -0400 | [diff] [blame] | 39 | } |