github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/apigw/v2/responses/testing/requests_test.go (about) 1 package testing 2 3 import ( 4 "testing" 5 6 "github.com/huaweicloud/golangsdk/openstack/apigw/v2/responses" 7 th "github.com/huaweicloud/golangsdk/testhelper" 8 "github.com/huaweicloud/golangsdk/testhelper/client" 9 ) 10 11 func TestCreateV2Responses(t *testing.T) { 12 th.SetupHTTP() 13 defer th.TeardownHTTP() 14 handleV2ResponsesCreate(t) 15 16 actual, err := responses.Create(client.ServiceClient(), createOpts).Extract() 17 th.AssertNoErr(t, err) 18 th.AssertDeepEquals(t, expectedCreateResponseData, actual) 19 } 20 21 func TestGetV2Responses(t *testing.T) { 22 th.SetupHTTP() 23 defer th.TeardownHTTP() 24 handleV2ResponsesGet(t) 25 26 actual, err := responses.Get(client.ServiceClient(), "9b76174b785342078e557f23c01d5e41", 27 "d060ade0560a4c01b89bf954ad2e9d6e", "baabc69fdb8f4c458637666c0441e9a4").Extract() 28 th.AssertNoErr(t, err) 29 th.AssertDeepEquals(t, expectedCreateResponseData, actual) 30 } 31 32 func TestListV2Responses(t *testing.T) { 33 th.SetupHTTP() 34 defer th.TeardownHTTP() 35 handleV2ResponsesList(t) 36 37 pages, err := responses.List(client.ServiceClient(), listOpts).AllPages() 38 th.AssertNoErr(t, err) 39 actual, err := responses.ExtractResponses(pages) 40 th.AssertNoErr(t, err) 41 th.AssertDeepEquals(t, expectedListResponseData, actual) 42 } 43 44 func TestUpdateV2Responses(t *testing.T) { 45 th.SetupHTTP() 46 defer th.TeardownHTTP() 47 handleV2ResponsesUpdate(t) 48 49 actual, err := responses.Update(client.ServiceClient(), "baabc69fdb8f4c458637666c0441e9a4", updateOpts).Extract() 50 th.AssertNoErr(t, err) 51 th.AssertDeepEquals(t, expectedCreateResponseData, actual) 52 } 53 54 func TestDeleteV2Responses(t *testing.T) { 55 th.SetupHTTP() 56 defer th.TeardownHTTP() 57 handleV2ResponsesDelete(t) 58 59 err := responses.Delete(client.ServiceClient(), "9b76174b785342078e557f23c01d5e41", 60 "d060ade0560a4c01b89bf954ad2e9d6e", "baabc69fdb8f4c458637666c0441e9a4").ExtractErr() 61 th.AssertNoErr(t, err) 62 } 63 64 func TestGetV2SpecResponse(t *testing.T) { 65 th.SetupHTTP() 66 defer th.TeardownHTTP() 67 handleV2SpecResponseGet(t) 68 69 errorType := "ACCESS_DENIED" 70 actual, err := responses.GetSpecResp(client.ServiceClient(), errorType, 71 specRespOpts).ExtractSpecResp("ACCESS_DENIED") 72 th.AssertNoErr(t, err) 73 th.AssertDeepEquals(t, expectedGetSpecResponseData, actual) 74 } 75 76 func TestUpdateV2SpecResponse(t *testing.T) { 77 th.SetupHTTP() 78 defer th.TeardownHTTP() 79 handleV2SpecResponseUpdate(t) 80 81 errorType := "ACCESS_DENIED" 82 actual, err := responses.UpdateSpecResp(client.ServiceClient(), errorType, specRespOpts, 83 responseInfoOpts).ExtractSpecResp("ACCESS_DENIED") 84 th.AssertNoErr(t, err) 85 th.AssertDeepEquals(t, expectedGetSpecResponseData, actual) 86 } 87 88 func TestDeleteV2SpecResponse(t *testing.T) { 89 th.SetupHTTP() 90 defer th.TeardownHTTP() 91 handleV2SpecResponseDelete(t) 92 93 errorType := "ACCESS_DENIED" 94 err := responses.DeleteSpecResp(client.ServiceClient(), errorType, specRespOpts).ExtractErr() 95 th.AssertNoErr(t, err) 96 }