github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/openstack/containerinfra/v1/quotas/testing/requests_test.go (about)

     1  package testing
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/vnpaycloud-console/gophercloud/v2/openstack/containerinfra/v1/quotas"
     8  	th "github.com/vnpaycloud-console/gophercloud/v2/testhelper"
     9  	fake "github.com/vnpaycloud-console/gophercloud/v2/testhelper/client"
    10  )
    11  
    12  func TestCreateQuota(t *testing.T) {
    13  	th.SetupHTTP()
    14  	defer th.TeardownHTTP()
    15  
    16  	HandleCreateQuotaSuccessfully(t)
    17  
    18  	opts := quotas.CreateOpts{
    19  		ProjectID: "aa5436ab58144c768ca4e9d2e9f5c3b2",
    20  		Resource:  "Cluster",
    21  		HardLimit: 10,
    22  	}
    23  
    24  	sc := fake.ServiceClient()
    25  	sc.Endpoint = sc.Endpoint + "v1/"
    26  
    27  	res := quotas.Create(context.TODO(), sc, opts)
    28  	th.AssertNoErr(t, res.Err)
    29  
    30  	requestID := res.Header.Get("X-OpenStack-Request-Id")
    31  	th.AssertEquals(t, requestUUID, requestID)
    32  
    33  	quota, err := res.Extract()
    34  	th.AssertNoErr(t, err)
    35  
    36  	th.AssertDeepEquals(t, projectID, quota.ProjectID)
    37  }