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