blob: e7869d8d871ef6cb0bb5ca53deb436bc64379285 [file] [log] [blame]
jrperritt3d966162016-06-06 14:08:54 -05001package testing
Ash Wilsonad13c422014-10-03 08:35:46 -04002
3import (
Ash Wilsonad13c422014-10-03 08:35:46 -04004 "testing"
5
jrperritt3d966162016-06-06 14:08:54 -05006 common "github.com/gophercloud/gophercloud/openstack/common/extensions/testing"
7 "github.com/gophercloud/gophercloud/openstack/identity/v2/extensions"
Jon Perritt27249f42016-02-18 10:35:59 -06008 "github.com/gophercloud/gophercloud/pagination"
9 th "github.com/gophercloud/gophercloud/testhelper"
10 "github.com/gophercloud/gophercloud/testhelper/client"
Ash Wilsonad13c422014-10-03 08:35:46 -040011)
12
Ash Wilsonad13c422014-10-03 08:35:46 -040013func TestList(t *testing.T) {
14 th.SetupHTTP()
15 defer th.TeardownHTTP()
Ash Wilson07a25bf2014-10-13 12:00:32 -040016 HandleListExtensionsSuccessfully(t)
Ash Wilsonad13c422014-10-03 08:35:46 -040017
18 count := 0
jrperritt3d966162016-06-06 14:08:54 -050019 err := extensions.List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
Ash Wilsonad13c422014-10-03 08:35:46 -040020 count++
jrperritt3d966162016-06-06 14:08:54 -050021 actual, err := extensions.ExtractExtensions(page)
Ash Wilsonfbedc672014-10-03 16:34:22 -040022 th.AssertNoErr(t, err)
Ash Wilson07a25bf2014-10-13 12:00:32 -040023 th.CheckDeepEquals(t, common.ExpectedExtensions, actual)
Ash Wilsonad13c422014-10-03 08:35:46 -040024
25 return true, nil
26 })
Ash Wilsonfbedc672014-10-03 16:34:22 -040027 th.AssertNoErr(t, err)
28 th.CheckEquals(t, 1, count)
Ash Wilsonad13c422014-10-03 08:35:46 -040029}
30
31func TestGet(t *testing.T) {
32 th.SetupHTTP()
33 defer th.TeardownHTTP()
Ash Wilson07a25bf2014-10-13 12:00:32 -040034 common.HandleGetExtensionSuccessfully(t)
Ash Wilsonad13c422014-10-03 08:35:46 -040035
jrperritt3d966162016-06-06 14:08:54 -050036 actual, err := extensions.Get(client.ServiceClient(), "agent").Extract()
Ash Wilson07a25bf2014-10-13 12:00:32 -040037 th.AssertNoErr(t, err)
38 th.CheckDeepEquals(t, common.SingleExtension, actual)
Ash Wilsonad13c422014-10-03 08:35:46 -040039}