github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/apigw/v2/environments/testing/requests_test.go (about) 1 package testing 2 3 import ( 4 "testing" 5 6 "github.com/huaweicloud/golangsdk/openstack/apigw/v2/environments" 7 th "github.com/huaweicloud/golangsdk/testhelper" 8 "github.com/huaweicloud/golangsdk/testhelper/client" 9 ) 10 11 func TestCreateV2Environment(t *testing.T) { 12 th.SetupHTTP() 13 defer th.TeardownHTTP() 14 handleV2EnvironmentCreate(t) 15 16 actual, err := environments.Create(client.ServiceClient(), "cc4ea721cc6747f7969e06bd21121c52", 17 createOpts).Extract() 18 th.AssertNoErr(t, err) 19 th.AssertDeepEquals(t, expectedCreateResponseData, actual) 20 } 21 22 func TestListV2Environment(t *testing.T) { 23 th.SetupHTTP() 24 defer th.TeardownHTTP() 25 handleV2EnvironmentList(t) 26 27 pages, err := environments.List(client.ServiceClient(), "cc4ea721cc6747f7969e06bd21121c52", 28 environments.ListOpts{}).AllPages() 29 th.AssertNoErr(t, err) 30 actual, err := environments.ExtractEnvironments(pages) 31 th.AssertNoErr(t, err) 32 th.AssertDeepEquals(t, expectedListResponseData, actual) 33 } 34 35 func TestUpdateV2Environment(t *testing.T) { 36 th.SetupHTTP() 37 defer th.TeardownHTTP() 38 handleV2EnvironmentUpdate(t) 39 40 actual, err := environments.Update(client.ServiceClient(), "cc4ea721cc6747f7969e06bd21121c52", 41 "3585fce96a5d44f8b445121b9440274a", updateOpts).Extract() 42 th.AssertNoErr(t, err) 43 th.AssertDeepEquals(t, expectedUpdateResponseData, actual) 44 } 45 46 func TestDeleteV2Environment(t *testing.T) { 47 th.SetupHTTP() 48 defer th.TeardownHTTP() 49 handleV2EnvironmentDelete(t) 50 51 err := environments.Delete(client.ServiceClient(), "cc4ea721cc6747f7969e06bd21121c52", 52 "3585fce96a5d44f8b445121b9440274a").ExtractErr() 53 th.AssertNoErr(t, err) 54 } 55 56 func TestCreateV2EnvironmentVariable(t *testing.T) { 57 th.SetupHTTP() 58 defer th.TeardownHTTP() 59 handleV2EnvironmentVariableCreate(t) 60 61 actual, err := environments.CreateVariable(client.ServiceClient(), "cc4ea721cc6747f7969e06bd21121c52", 62 variableCreateOpts).Extract() 63 th.AssertNoErr(t, err) 64 th.AssertDeepEquals(t, expectedCreateVariableResponseData, actual) 65 } 66 67 func TestGetV2EnvironmentVariable(t *testing.T) { 68 th.SetupHTTP() 69 defer th.TeardownHTTP() 70 handleV2EnvironmentVariableGet(t) 71 72 actual, err := environments.GetVariable(client.ServiceClient(), "cc4ea721cc6747f7969e06bd21121c52", 73 "2dc48632332f4157804175175e71e3e8").Extract() 74 th.AssertNoErr(t, err) 75 th.AssertDeepEquals(t, expectedCreateVariableResponseData, actual) 76 } 77 78 func TestListV2EnvironmentVariable(t *testing.T) { 79 th.SetupHTTP() 80 defer th.TeardownHTTP() 81 handleV2EnvironmentVariableList(t) 82 83 pages, err := environments.ListVariables(client.ServiceClient(), "cc4ea721cc6747f7969e06bd21121c52", 84 environments.ListVariablesOpts{}).AllPages() 85 th.AssertNoErr(t, err) 86 actual, err := environments.ExtractVariables(pages) 87 th.AssertNoErr(t, err) 88 th.AssertDeepEquals(t, expectedListVariableResponseData, actual) 89 } 90 91 func TestDeleteV2EnvironmentVariable(t *testing.T) { 92 th.SetupHTTP() 93 defer th.TeardownHTTP() 94 handleV2EnvironmentVariableDelete(t) 95 96 err := environments.DeleteVariable(client.ServiceClient(), "cc4ea721cc6747f7969e06bd21121c52", 97 "2dc48632332f4157804175175e71e3e8").ExtractErr() 98 th.AssertNoErr(t, err) 99 }