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