blob: 822093ff477a89b55fae597c023b40e53814ce02 [file] [log] [blame]
jrperritt3d966162016-06-06 14:08:54 -05001package testing
2
3import (
4 "testing"
5
6 common "github.com/gophercloud/gophercloud/openstack/common/extensions"
7 "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions"
8 "github.com/gophercloud/gophercloud/pagination"
9 th "github.com/gophercloud/gophercloud/testhelper"
10 "github.com/gophercloud/gophercloud/testhelper/client"
11)
12
13func TestList(t *testing.T) {
14 th.SetupHTTP()
15 defer th.TeardownHTTP()
16
17 HandleListExtensionsSuccessfully(t)
18
19 count := 0
20 extensions.List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
21 count++
22 actual, err := extensions.ExtractExtensions(page)
23 th.AssertNoErr(t, err)
24
25 expected := []common.Extension{
26 common.Extension{
27 Updated: "2013-01-20T00:00:00-00:00",
28 Name: "Neutron Service Type Management",
29 Links: []interface{}{},
30 Namespace: "http://docs.openstack.org/ext/neutron/service-type/api/v1.0",
31 Alias: "service-type",
32 Description: "API for retrieving service providers for Neutron advanced services",
33 },
34 }
35 th.AssertDeepEquals(t, expected, actual)
36
37 return true, nil
38 })
39 th.CheckEquals(t, 1, count)
40}
41
42func TestGet(t *testing.T) {
43 th.SetupHTTP()
44 defer th.TeardownHTTP()
45
46 HandleGetExtensionsSuccessfully(t)
47
48 ext, err := extensions.Get(client.ServiceClient(), "agent").Extract()
49 th.AssertNoErr(t, err)
50
51 th.AssertEquals(t, ext.Updated, "2013-02-03T10:00:00-00:00")
52 th.AssertEquals(t, ext.Name, "agent")
53 th.AssertEquals(t, ext.Namespace, "http://docs.openstack.org/ext/agent/api/v2.0")
54 th.AssertEquals(t, ext.Alias, "agent")
55 th.AssertEquals(t, ext.Description, "The agent management extension.")
56}