github.com/gophercloud/gophercloud@v1.11.0/openstack/clustering/v1/actions/testing/requests_test.go (about)

     1  package testing
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/gophercloud/gophercloud/openstack/clustering/v1/actions"
     7  	"github.com/gophercloud/gophercloud/pagination"
     8  	th "github.com/gophercloud/gophercloud/testhelper"
     9  	fake "github.com/gophercloud/gophercloud/testhelper/client"
    10  )
    11  
    12  func TestListActions(t *testing.T) {
    13  	th.SetupHTTP()
    14  	defer th.TeardownHTTP()
    15  
    16  	HandleListSuccessfully(t)
    17  
    18  	pageCount := 0
    19  	err := actions.List(fake.ServiceClient(), nil).EachPage(func(page pagination.Page) (bool, error) {
    20  		pageCount++
    21  		actual, err := actions.ExtractActions(page)
    22  		th.AssertNoErr(t, err)
    23  
    24  		th.AssertDeepEquals(t, ExpectedActions, actual)
    25  
    26  		return true, nil
    27  	})
    28  	th.AssertNoErr(t, err)
    29  
    30  	if pageCount != 1 {
    31  		t.Errorf("Expected 1 page, got %d", pageCount)
    32  	}
    33  }
    34  
    35  func TestGetAction(t *testing.T) {
    36  	th.SetupHTTP()
    37  	defer th.TeardownHTTP()
    38  
    39  	HandleGetSuccessfully(t, ExpectedAction1.ID)
    40  
    41  	actual, err := actions.Get(fake.ServiceClient(), ExpectedAction1.ID).Extract()
    42  	th.AssertNoErr(t, err)
    43  	th.AssertDeepEquals(t, ExpectedAction1, *actual)
    44  }