github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/openstack/sharedfilesystems/apiversions/testing/requests_test.go (about) 1 package testing 2 3 import ( 4 "context" 5 "testing" 6 7 "github.com/vnpaycloud-console/gophercloud/v2/openstack/sharedfilesystems/apiversions" 8 th "github.com/vnpaycloud-console/gophercloud/v2/testhelper" 9 "github.com/vnpaycloud-console/gophercloud/v2/testhelper/client" 10 ) 11 12 func TestListAPIVersions(t *testing.T) { 13 th.SetupHTTP() 14 defer th.TeardownHTTP() 15 16 MockListResponse(t) 17 18 allVersions, err := apiversions.List(client.ServiceClient()).AllPages(context.TODO()) 19 th.AssertNoErr(t, err) 20 21 actual, err := apiversions.ExtractAPIVersions(allVersions) 22 th.AssertNoErr(t, err) 23 24 th.AssertDeepEquals(t, ManilaAllAPIVersionResults, actual) 25 } 26 27 func TestGetAPIVersion(t *testing.T) { 28 th.SetupHTTP() 29 defer th.TeardownHTTP() 30 31 MockGetResponse(t) 32 33 actual, err := apiversions.Get(context.TODO(), client.ServiceClient(), "v2").Extract() 34 th.AssertNoErr(t, err) 35 36 th.AssertDeepEquals(t, ManilaAPIVersion2Result, *actual) 37 } 38 39 func TestGetNoAPIVersion(t *testing.T) { 40 th.SetupHTTP() 41 defer th.TeardownHTTP() 42 43 MockGetNoResponse(t) 44 45 _, err := apiversions.Get(context.TODO(), client.ServiceClient(), "v2").Extract() 46 th.AssertEquals(t, err.Error(), "Unable to find requested API version") 47 } 48 49 func TestGetMultipleAPIVersion(t *testing.T) { 50 th.SetupHTTP() 51 defer th.TeardownHTTP() 52 53 MockGetMultipleResponses(t) 54 55 _, err := apiversions.Get(context.TODO(), client.ServiceClient(), "v2").Extract() 56 th.AssertEquals(t, err.Error(), "Found 2 API versions") 57 }