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

     1  package testing
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/huaweicloud/golangsdk/openstack/compute/v2/extensions/tenantnetworks"
     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  	HandleListSuccessfully(t)
    16  
    17  	count := 0
    18  	err := tenantnetworks.List(client.ServiceClient()).EachPage(func(page pagination.Page) (bool, error) {
    19  		count++
    20  		actual, err := tenantnetworks.ExtractNetworks(page)
    21  		th.AssertNoErr(t, err)
    22  		th.CheckDeepEquals(t, ExpectedNetworkSlice, actual)
    23  
    24  		return true, nil
    25  	})
    26  	th.AssertNoErr(t, err)
    27  	th.CheckEquals(t, 1, count)
    28  }
    29  
    30  func TestGet(t *testing.T) {
    31  	th.SetupHTTP()
    32  	defer th.TeardownHTTP()
    33  	HandleGetSuccessfully(t)
    34  
    35  	actual, err := tenantnetworks.Get(client.ServiceClient(), "20c8acc0-f747-4d71-a389-46d078ebf000").Extract()
    36  	th.AssertNoErr(t, err)
    37  	th.CheckDeepEquals(t, &SecondNetwork, actual)
    38  }