blob: 6550283df71c2e99cc191c03523b0b8038fe8f18 [file] [log] [blame]
Ash Wilson61dcb022014-10-03 08:15:47 -04001package extensions
2
3import (
Ash Wilson61dcb022014-10-03 08:15:47 -04004 "testing"
5
Ash Wilson61dcb022014-10-03 08:15:47 -04006 "github.com/rackspace/gophercloud/pagination"
7 th "github.com/rackspace/gophercloud/testhelper"
Ash Wilsonce942a82014-10-13 11:48:01 -04008 "github.com/rackspace/gophercloud/testhelper/client"
Ash Wilson61dcb022014-10-03 08:15:47 -04009)
10
Ash Wilson61dcb022014-10-03 08:15:47 -040011func TestList(t *testing.T) {
12 th.SetupHTTP()
13 defer th.TeardownHTTP()
Ash Wilsonce942a82014-10-13 11:48:01 -040014 HandleListExtensionsSuccessfully(t)
Ash Wilson61dcb022014-10-03 08:15:47 -040015
16 count := 0
17
Ash Wilsonce942a82014-10-13 11:48:01 -040018 List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
Ash Wilson61dcb022014-10-03 08:15:47 -040019 count++
20 actual, err := ExtractExtensions(page)
Ash Wilsonce942a82014-10-13 11:48:01 -040021 th.AssertNoErr(t, err)
22 th.AssertDeepEquals(t, ExpectedExtensions, actual)
Ash Wilson61dcb022014-10-03 08:15:47 -040023
24 return true, nil
25 })
26
Ash Wilsonce942a82014-10-13 11:48:01 -040027 th.CheckEquals(t, 1, count)
Ash Wilson61dcb022014-10-03 08:15:47 -040028}
29
30func TestGet(t *testing.T) {
31 th.SetupHTTP()
32 defer th.TeardownHTTP()
Ash Wilsonce942a82014-10-13 11:48:01 -040033 HandleGetExtensionSuccessfully(t)
Ash Wilson61dcb022014-10-03 08:15:47 -040034
Ash Wilsonce942a82014-10-13 11:48:01 -040035 actual, err := Get(client.ServiceClient(), "agent").Extract()
36 th.AssertNoErr(t, err)
37 th.CheckDeepEquals(t, SingleExtension, actual)
Ash Wilson61dcb022014-10-03 08:15:47 -040038}