blob: fbaedfa0bed6619d59f435ede093f8d1483f6ea5 [file] [log] [blame]
jrperritt3d966162016-06-06 14:08:54 -05001package testing
Ash Wilson61dcb022014-10-03 08:15:47 -04002
3import (
Ash Wilson61dcb022014-10-03 08:15:47 -04004 "testing"
5
jrperritt3d966162016-06-06 14:08:54 -05006 "github.com/gophercloud/gophercloud/openstack/common/extensions"
Jon Perritt27249f42016-02-18 10:35:59 -06007 "github.com/gophercloud/gophercloud/pagination"
8 th "github.com/gophercloud/gophercloud/testhelper"
9 "github.com/gophercloud/gophercloud/testhelper/client"
Ash Wilson61dcb022014-10-03 08:15:47 -040010)
11
Ash Wilson61dcb022014-10-03 08:15:47 -040012func TestList(t *testing.T) {
13 th.SetupHTTP()
14 defer th.TeardownHTTP()
Ash Wilsonce942a82014-10-13 11:48:01 -040015 HandleListExtensionsSuccessfully(t)
Ash Wilson61dcb022014-10-03 08:15:47 -040016
17 count := 0
18
jrperritt3d966162016-06-06 14:08:54 -050019 extensions.List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
Ash Wilson61dcb022014-10-03 08:15:47 -040020 count++
jrperritt3d966162016-06-06 14:08:54 -050021 actual, err := extensions.ExtractExtensions(page)
Ash Wilsonce942a82014-10-13 11:48:01 -040022 th.AssertNoErr(t, err)
23 th.AssertDeepEquals(t, ExpectedExtensions, actual)
Ash Wilson61dcb022014-10-03 08:15:47 -040024
25 return true, nil
26 })
27
Ash Wilsonce942a82014-10-13 11:48:01 -040028 th.CheckEquals(t, 1, count)
Ash Wilson61dcb022014-10-03 08:15:47 -040029}
30
31func TestGet(t *testing.T) {
32 th.SetupHTTP()
33 defer th.TeardownHTTP()
Ash Wilsonce942a82014-10-13 11:48:01 -040034 HandleGetExtensionSuccessfully(t)
Ash Wilson61dcb022014-10-03 08:15:47 -040035
jrperritt3d966162016-06-06 14:08:54 -050036 actual, err := extensions.Get(client.ServiceClient(), "agent").Extract()
Ash Wilsonce942a82014-10-13 11:48:01 -040037 th.AssertNoErr(t, err)
38 th.CheckDeepEquals(t, SingleExtension, actual)
Ash Wilson61dcb022014-10-03 08:15:47 -040039}