github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/openstack/sharedfilesystems/v2/errors/testing/request_test.go (about)

     1  package testing
     2  
     3  import (
     4  	"context"
     5  	"testing"
     6  
     7  	"github.com/vnpaycloud-console/gophercloud/v2/openstack/sharedfilesystems/v2/errors"
     8  	"github.com/vnpaycloud-console/gophercloud/v2/openstack/sharedfilesystems/v2/shares"
     9  	th "github.com/vnpaycloud-console/gophercloud/v2/testhelper"
    10  	"github.com/vnpaycloud-console/gophercloud/v2/testhelper/client"
    11  )
    12  
    13  func TestCreate(t *testing.T) {
    14  	th.SetupHTTP()
    15  	defer th.TeardownHTTP()
    16  
    17  	MockCreateResponse(t)
    18  
    19  	options := &shares.CreateOpts{Size: 1, Name: "my_test_share", ShareProto: "NFS", SnapshotID: "70bfbebc-d3ff-4528-8bbb-58422daa280b"}
    20  	_, err := shares.Create(context.TODO(), client.ServiceClient(), options).Extract()
    21  
    22  	if err == nil {
    23  		t.Fatal("Expected error")
    24  	}
    25  
    26  	detailedErr := errors.ErrorDetails{}
    27  	e := errors.ExtractErrorInto(err, &detailedErr)
    28  	th.AssertNoErr(t, e)
    29  
    30  	for k, msg := range detailedErr {
    31  		th.AssertEquals(t, k, "itemNotFound")
    32  		th.AssertEquals(t, msg.Code, 404)
    33  		th.AssertEquals(t, msg.Message, "ShareSnapshotNotFound: Snapshot 70bfbebc-d3ff-4528-8bbb-58422daa280b could not be found.")
    34  	}
    35  }