github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/openstack/containerinfra/v1/certificates/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/certificates"
     8  	th "github.com/vnpaycloud-console/gophercloud/v2/testhelper"
     9  	fake "github.com/vnpaycloud-console/gophercloud/v2/testhelper/client"
    10  )
    11  
    12  func TestGetCertificates(t *testing.T) {
    13  	th.SetupHTTP()
    14  	defer th.TeardownHTTP()
    15  
    16  	HandleGetCertificateSuccessfully(t)
    17  
    18  	sc := fake.ServiceClient()
    19  	sc.Endpoint = sc.Endpoint + "v1/"
    20  
    21  	actual, err := certificates.Get(context.TODO(), sc, "d564b18a-2890-4152-be3d-e05d784ff72").Extract()
    22  	th.AssertNoErr(t, err)
    23  	th.AssertDeepEquals(t, ExpectedCertificate, *actual)
    24  }
    25  
    26  func TestCreateCertificates(t *testing.T) {
    27  	th.SetupHTTP()
    28  	defer th.TeardownHTTP()
    29  
    30  	HandleCreateCertificateSuccessfully(t)
    31  
    32  	sc := fake.ServiceClient()
    33  	sc.Endpoint = sc.Endpoint + "v1/"
    34  
    35  	opts := certificates.CreateOpts{
    36  		BayUUID: "d564b18a-2890-4152-be3d-e05d784ff727",
    37  		CSR:     "FAKE_CERTIFICATE_CSR",
    38  	}
    39  
    40  	actual, err := certificates.Create(context.TODO(), sc, opts).Extract()
    41  	th.AssertNoErr(t, err)
    42  	th.AssertDeepEquals(t, ExpectedCreateCertificateResponse, *actual)
    43  }
    44  
    45  func TestUpdateCertificates(t *testing.T) {
    46  	th.SetupHTTP()
    47  	defer th.TeardownHTTP()
    48  
    49  	HandleUpdateCertificateSuccessfully(t)
    50  
    51  	sc := fake.ServiceClient()
    52  	sc.Endpoint = sc.Endpoint + "v1/"
    53  
    54  	err := certificates.Update(context.TODO(), sc, "d564b18a-2890-4152-be3d-e05d784ff72").ExtractErr()
    55  	th.AssertNoErr(t, err)
    56  }