github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/apigw/v2/instances/testing/requests_test.go (about) 1 package testing 2 3 import ( 4 "testing" 5 6 "github.com/huaweicloud/golangsdk/openstack/apigw/v2/instances" 7 th "github.com/huaweicloud/golangsdk/testhelper" 8 "github.com/huaweicloud/golangsdk/testhelper/client" 9 ) 10 11 func TestCreateV2Instance(t *testing.T) { 12 th.SetupHTTP() 13 defer th.TeardownHTTP() 14 handleV2InstanceCreate(t) 15 16 actual, err := instances.Create(client.ServiceClient(), createOpts).Extract() 17 th.AssertNoErr(t, err) 18 th.AssertDeepEquals(t, expectedCreateResponseData, actual) 19 } 20 21 func TestGetV2Instance(t *testing.T) { 22 th.SetupHTTP() 23 defer th.TeardownHTTP() 24 handleV2InstanceGet(t) 25 26 actual, err := instances.Get(client.ServiceClient(), "e6a5871bfb5b47d19c5874790f639ef8").Extract() 27 th.AssertNoErr(t, err) 28 th.AssertDeepEquals(t, expectedGetResponseData, actual) 29 } 30 31 func TestListV2Instance(t *testing.T) { 32 th.SetupHTTP() 33 defer th.TeardownHTTP() 34 handleV2InstanceList(t) 35 36 pages, err := instances.List(client.ServiceClient(), instances.ListOpts{}).AllPages() 37 th.AssertNoErr(t, err) 38 actual, err := instances.ExtractInstances(pages) 39 th.AssertNoErr(t, err) 40 th.AssertDeepEquals(t, expectedListResponseData, actual) 41 } 42 43 func TestUpdateV2Instance(t *testing.T) { 44 th.SetupHTTP() 45 defer th.TeardownHTTP() 46 handleV2InstanceUpdate(t) 47 48 actual, err := instances.Update(client.ServiceClient(), "e6a5871bfb5b47d19c5874790f639ef8", updateOpts).Extract() 49 th.AssertNoErr(t, err) 50 th.AssertDeepEquals(t, expectedGetResponseData, actual) 51 } 52 53 func TestDeleteV2Instance(t *testing.T) { 54 th.SetupHTTP() 55 defer th.TeardownHTTP() 56 handleV2InstanceDelete(t) 57 58 err := instances.Delete(client.ServiceClient(), "e6a5871bfb5b47d19c5874790f639ef8").ExtractErr() 59 th.AssertNoErr(t, err) 60 } 61 62 func TestDisableEgressV2Instance(t *testing.T) { 63 th.SetupHTTP() 64 defer th.TeardownHTTP() 65 handleV2InstanceEgressDisable(t) 66 67 err := instances.DisableEgressAccess(client.ServiceClient(), "e6a5871bfb5b47d19c5874790f639ef8").ExtractErr() 68 th.AssertNoErr(t, err) 69 } 70 71 func TestDisableIngressV2Instance(t *testing.T) { 72 th.SetupHTTP() 73 defer th.TeardownHTTP() 74 handleV2InstanceIngressDisable(t) 75 76 err := instances.DisableIngressAccess(client.ServiceClient(), "e6a5871bfb5b47d19c5874790f639ef8").ExtractErr() 77 th.AssertNoErr(t, err) 78 }