github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/apigw/v2/throttles/testing/requests_test.go (about) 1 package testing 2 3 import ( 4 "testing" 5 6 "github.com/huaweicloud/golangsdk/openstack/apigw/v2/throttles" 7 th "github.com/huaweicloud/golangsdk/testhelper" 8 "github.com/huaweicloud/golangsdk/testhelper/client" 9 ) 10 11 func TestCreateV2ThrottlingPolicy(t *testing.T) { 12 th.SetupHTTP() 13 defer th.TeardownHTTP() 14 handleV2ThrottlingPolicyCreate(t) 15 16 actual, err := throttles.Create(client.ServiceClient(), "6da953fe33d44650a067e43a4593368b", createOpts).Extract() 17 th.AssertNoErr(t, err) 18 th.AssertDeepEquals(t, expectedCreateResponseData, actual) 19 } 20 21 func TestGetV2ThrottlingPolicy(t *testing.T) { 22 th.SetupHTTP() 23 defer th.TeardownHTTP() 24 handleV2ThrottlingPolicyGet(t) 25 26 actual, err := throttles.Get(client.ServiceClient(), "6da953fe33d44650a067e43a4593368b", 27 "c481043838f64bcd82c7b0c38907d59d").Extract() 28 th.AssertNoErr(t, err) 29 th.AssertDeepEquals(t, expectedCreateResponseData, actual) 30 } 31 32 func TestListV2ThrottlingPolicy(t *testing.T) { 33 th.SetupHTTP() 34 defer th.TeardownHTTP() 35 handleV2ThrottlingPolicyList(t) 36 37 pages, err := throttles.List(client.ServiceClient(), "6da953fe33d44650a067e43a4593368b", 38 listOpts).AllPages() 39 th.AssertNoErr(t, err) 40 actual, err := throttles.ExtractPolicies(pages) 41 th.AssertNoErr(t, err) 42 th.AssertDeepEquals(t, expectedListResponseData, actual) 43 } 44 45 func TestUpdateV2ThrottlingPolicy(t *testing.T) { 46 th.SetupHTTP() 47 defer th.TeardownHTTP() 48 handleV2ThrottlingPolicyUpdate(t) 49 50 actual, err := throttles.Update(client.ServiceClient(), "6da953fe33d44650a067e43a4593368b", 51 "c481043838f64bcd82c7b0c38907d59d", createOpts).Extract() 52 th.AssertNoErr(t, err) 53 th.AssertDeepEquals(t, expectedCreateResponseData, actual) 54 } 55 56 func TestDeleteV2ThrottlingPolicy(t *testing.T) { 57 th.SetupHTTP() 58 defer th.TeardownHTTP() 59 handleV2ThrottlingPolicyDelete(t) 60 61 err := throttles.Delete(client.ServiceClient(), "6da953fe33d44650a067e43a4593368b", 62 "c481043838f64bcd82c7b0c38907d59d").ExtractErr() 63 th.AssertNoErr(t, err) 64 } 65 66 func TestCreateV2SpecThrottlingPolicy(t *testing.T) { 67 th.SetupHTTP() 68 defer th.TeardownHTTP() 69 handleV2SpecThrottlingPolicyCreate(t) 70 71 actual, err := throttles.CreateSpecThrottle(client.ServiceClient(), "6da953fe33d44650a067e43a4593368b", 72 "c481043838f64bcd82c7b0c38907d59d", specThrottleCreateOpts).Extract() 73 th.AssertNoErr(t, err) 74 th.AssertDeepEquals(t, expectedSpecCreateResponseData, actual) 75 } 76 77 func TestListV2SpecThrottlingPolicy(t *testing.T) { 78 th.SetupHTTP() 79 defer th.TeardownHTTP() 80 handleV2SpecThrottlingPolicyList(t) 81 82 pages, err := throttles.ListSpecThrottles(client.ServiceClient(), "6da953fe33d44650a067e43a4593368b", 83 "c481043838f64bcd82c7b0c38907d59d", specThrottleListOpts).AllPages() 84 th.AssertNoErr(t, err) 85 actual, err := throttles.ExtractSpecThrottles(pages) 86 th.AssertNoErr(t, err) 87 th.AssertDeepEquals(t, expectedSpecListResponseData, actual) 88 } 89 90 func TestUpdateV2SpecThrottlingPolicy(t *testing.T) { 91 th.SetupHTTP() 92 defer th.TeardownHTTP() 93 handleV2SpecThrottlingPolicyUpdate(t) 94 95 actual, err := throttles.UpdateSpecThrottle(client.ServiceClient(), "6da953fe33d44650a067e43a4593368b", 96 "c481043838f64bcd82c7b0c38907d59d", "aec8d27e3e034f4293bc766942ed60fd", specThrottleUpdateOpts).Extract() 97 th.AssertNoErr(t, err) 98 th.AssertDeepEquals(t, expectedSpecCreateResponseData, actual) 99 } 100 101 func TestDeleteV2SpecThrottlingPolicy(t *testing.T) { 102 th.SetupHTTP() 103 defer th.TeardownHTTP() 104 handleV2SpecThrottlingPolicyDelete(t) 105 106 err := throttles.DeleteSpecThrottle(client.ServiceClient(), "6da953fe33d44650a067e43a4593368b", 107 "c481043838f64bcd82c7b0c38907d59d", "aec8d27e3e034f4293bc766942ed60fd").ExtractErr() 108 th.AssertNoErr(t, err) 109 }