blob: 504118a825ba5fa89d581b9465799cf173aeb47a [file] [log] [blame]
Ash Wilsonad13c422014-10-03 08:35:46 -04001package extensions
2
3import (
Ash Wilsonad13c422014-10-03 08:35:46 -04004 "testing"
5
Ash Wilsonad13c422014-10-03 08:35:46 -04006 common "github.com/rackspace/gophercloud/openstack/common/extensions"
7 "github.com/rackspace/gophercloud/pagination"
8 th "github.com/rackspace/gophercloud/testhelper"
Ash Wilson07a25bf2014-10-13 12:00:32 -04009 "github.com/rackspace/gophercloud/testhelper/client"
Ash Wilsonad13c422014-10-03 08:35:46 -040010)
11
Ash Wilsonad13c422014-10-03 08:35:46 -040012func TestList(t *testing.T) {
13 th.SetupHTTP()
14 defer th.TeardownHTTP()
Ash Wilson07a25bf2014-10-13 12:00:32 -040015 HandleListExtensionsSuccessfully(t)
Ash Wilsonad13c422014-10-03 08:35:46 -040016
17 count := 0
Ash Wilson07a25bf2014-10-13 12:00:32 -040018 err := List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
Ash Wilsonad13c422014-10-03 08:35:46 -040019 count++
20 actual, err := ExtractExtensions(page)
Ash Wilsonfbedc672014-10-03 16:34:22 -040021 th.AssertNoErr(t, err)
Ash Wilson07a25bf2014-10-13 12:00:32 -040022 th.CheckDeepEquals(t, common.ExpectedExtensions, actual)
Ash Wilsonad13c422014-10-03 08:35:46 -040023
24 return true, nil
25 })
Ash Wilsonfbedc672014-10-03 16:34:22 -040026 th.AssertNoErr(t, err)
27 th.CheckEquals(t, 1, count)
Ash Wilsonad13c422014-10-03 08:35:46 -040028}
29
30func TestGet(t *testing.T) {
31 th.SetupHTTP()
32 defer th.TeardownHTTP()
Ash Wilson07a25bf2014-10-13 12:00:32 -040033 common.HandleGetExtensionSuccessfully(t)
Ash Wilsonad13c422014-10-03 08:35:46 -040034
Ash Wilson07a25bf2014-10-13 12:00:32 -040035 actual, err := Get(client.ServiceClient(), "agent").Extract()
36 th.AssertNoErr(t, err)
37 th.CheckDeepEquals(t, common.SingleExtension, actual)
Ash Wilsonad13c422014-10-03 08:35:46 -040038}