github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/openstack/blockstorage/v3/schedulerstats/testing/requests_test.go (about)

     1  package testing
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/vnpaycloud-console/gophercloud/v2/openstack/blockstorage/v3/schedulerstats"
     8  	"github.com/vnpaycloud-console/gophercloud/v2/pagination"
     9  	th "github.com/vnpaycloud-console/gophercloud/v2/testhelper"
    10  	"github.com/vnpaycloud-console/gophercloud/v2/testhelper/client"
    11  )
    12  
    13  func TestListStoragePoolsDetail(t *testing.T) {
    14  	th.SetupHTTP()
    15  	defer th.TeardownHTTP()
    16  	HandleStoragePoolsListSuccessfully(t)
    17  
    18  	pages := 0
    19  	err := schedulerstats.List(client.ServiceClient(), schedulerstats.ListOpts{Detail: true}).EachPage(context.TODO(), func(_ context.Context, page pagination.Page) (bool, error) {
    20  		pages++
    21  
    22  		actual, err := schedulerstats.ExtractStoragePools(page)
    23  		th.AssertNoErr(t, err)
    24  
    25  		if len(actual) != 2 {
    26  			t.Fatalf("Expected 2 backends, got %d", len(actual))
    27  		}
    28  		th.CheckDeepEquals(t, StoragePoolFake1, actual[0])
    29  		th.CheckDeepEquals(t, StoragePoolFake2, actual[1])
    30  
    31  		return true, nil
    32  	})
    33  
    34  	th.AssertNoErr(t, err)
    35  
    36  	if pages != 1 {
    37  		t.Errorf("Expected 1 page, saw %d", pages)
    38  	}
    39  }