blob: e30f79404dc107c51adf9a9d3f84f2599884566b [file] [log] [blame]
Ash Wilsonf4d63632014-10-09 14:54:06 -04001package extensions
2
3import (
Ash Wilsonf4d63632014-10-09 14:54:06 -04004 "testing"
5
6 common "github.com/rackspace/gophercloud/openstack/common/extensions"
Ash Wilsonf4d63632014-10-09 14:54:06 -04007 "github.com/rackspace/gophercloud/pagination"
8 th "github.com/rackspace/gophercloud/testhelper"
9 fake "github.com/rackspace/gophercloud/testhelper/client"
10)
11
12func TestList(t *testing.T) {
13 th.SetupHTTP()
14 defer th.TeardownHTTP()
Ash Wilson56d97a62014-10-13 12:07:47 -040015 common.HandleListExtensionsSuccessfully(t)
Ash Wilsonf4d63632014-10-09 14:54:06 -040016
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 Wilson56d97a62014-10-13 12:07:47 -040023 th.AssertDeepEquals(t, common.ExpectedExtensions, actual)
Ash Wilsonf4d63632014-10-09 14:54:06 -040024
25 return true, nil
26 })
27 th.AssertNoErr(t, err)
28 th.CheckEquals(t, 1, count)
29}
30
31func TestGet(t *testing.T) {
32 th.SetupHTTP()
33 defer th.TeardownHTTP()
Ash Wilson56d97a62014-10-13 12:07:47 -040034 common.HandleGetExtensionSuccessfully(t)
Ash Wilsonf4d63632014-10-09 14:54:06 -040035
Ash Wilson56d97a62014-10-13 12:07:47 -040036 actual, err := Get(fake.ServiceClient(), "agent").Extract()
37 th.AssertNoErr(t, err)
38 th.CheckDeepEquals(t, common.SingleExtension, actual)
Ash Wilsonf4d63632014-10-09 14:54:06 -040039}