github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/common/extensions/testing/requests_test.go (about)

     1  package testing
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/huaweicloud/golangsdk/openstack/common/extensions"
     7  	"github.com/huaweicloud/golangsdk/pagination"
     8  	th "github.com/huaweicloud/golangsdk/testhelper"
     9  	"github.com/huaweicloud/golangsdk/testhelper/client"
    10  )
    11  
    12  func TestList(t *testing.T) {
    13  	th.SetupHTTP()
    14  	defer th.TeardownHTTP()
    15  	HandleListExtensionsSuccessfully(t)
    16  
    17  	count := 0
    18  
    19  	extensions.List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
    20  		count++
    21  		actual, err := extensions.ExtractExtensions(page)
    22  		th.AssertNoErr(t, err)
    23  		th.AssertDeepEquals(t, ExpectedExtensions, actual)
    24  
    25  		return true, nil
    26  	})
    27  
    28  	th.CheckEquals(t, 1, count)
    29  }
    30  
    31  func TestGet(t *testing.T) {
    32  	th.SetupHTTP()
    33  	defer th.TeardownHTTP()
    34  	HandleGetExtensionSuccessfully(t)
    35  
    36  	actual, err := extensions.Get(client.ServiceClient(), "agent").Extract()
    37  	th.AssertNoErr(t, err)
    38  	th.CheckDeepEquals(t, SingleExtension, actual)
    39  }