github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/openstack/identity/v2/extensions/testing/requests_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/testing"
     8  	"github.com/vnpaycloud-console/gophercloud/v2/openstack/identity/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  	HandleListExtensionsSuccessfully(t)
    18  
    19  	count := 0
    20  	err := extensions.List(client.ServiceClient()).EachPage(context.TODO(), func(_ context.Context, page pagination.Page) (bool, error) {
    21  		count++
    22  		actual, err := extensions.ExtractExtensions(page)
    23  		th.AssertNoErr(t, err)
    24  		th.CheckDeepEquals(t, common.ExpectedExtensions, actual)
    25  
    26  		return true, nil
    27  	})
    28  	th.AssertNoErr(t, err)
    29  	th.CheckEquals(t, 1, count)
    30  }
    31  
    32  func TestGet(t *testing.T) {
    33  	th.SetupHTTP()
    34  	defer th.TeardownHTTP()
    35  	common.HandleGetExtensionSuccessfully(t)
    36  
    37  	actual, err := extensions.Get(context.TODO(), client.ServiceClient(), "agent").Extract()
    38  	th.AssertNoErr(t, err)
    39  	th.CheckDeepEquals(t, common.SingleExtension, actual)
    40  }