github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/apigw/v2/applications/testing/requests_test.go (about) 1 package testing 2 3 import ( 4 "testing" 5 6 "github.com/huaweicloud/golangsdk/openstack/apigw/v2/applications" 7 th "github.com/huaweicloud/golangsdk/testhelper" 8 "github.com/huaweicloud/golangsdk/testhelper/client" 9 ) 10 11 func TestCreateV2Application(t *testing.T) { 12 th.SetupHTTP() 13 defer th.TeardownHTTP() 14 handleV2ApplicationCreate(t) 15 16 actual, err := applications.Create(client.ServiceClient(), "c5faacb524d148b59ddd448dd02d016a", appOpts).Extract() 17 th.AssertNoErr(t, err) 18 th.AssertDeepEquals(t, expectedCreateResponseData, actual) 19 } 20 21 func TestGetV2Application(t *testing.T) { 22 th.SetupHTTP() 23 defer th.TeardownHTTP() 24 handleV2ApplicationGet(t) 25 26 actual, err := applications.Get(client.ServiceClient(), "c5faacb524d148b59ddd448dd02d016a", 27 "50f768cf1c1f4389965aa58d255b2a65").Extract() 28 th.AssertNoErr(t, err) 29 th.AssertDeepEquals(t, expectedGetResponseData, actual) 30 } 31 32 func TestListV2Application(t *testing.T) { 33 th.SetupHTTP() 34 defer th.TeardownHTTP() 35 handleV2ApplicationList(t) 36 37 pages, err := applications.List(client.ServiceClient(), "c5faacb524d148b59ddd448dd02d016a", 38 applications.ListOpts{}).AllPages() 39 th.AssertNoErr(t, err) 40 actual, err := applications.ExtractApplications(pages) 41 th.AssertNoErr(t, err) 42 th.AssertDeepEquals(t, expectedListResponseData, actual) 43 } 44 45 func TestUpdateV2Application(t *testing.T) { 46 th.SetupHTTP() 47 defer th.TeardownHTTP() 48 handleV2ApplicationUpdate(t) 49 50 actual, err := applications.Update(client.ServiceClient(), "c5faacb524d148b59ddd448dd02d016a", 51 "50f768cf1c1f4389965aa58d255b2a65", appOpts).Extract() 52 th.AssertNoErr(t, err) 53 th.AssertDeepEquals(t, expectedGetResponseData, actual) 54 } 55 56 func TestDeleteV2Application(t *testing.T) { 57 th.SetupHTTP() 58 defer th.TeardownHTTP() 59 handleV2ApplicationDelete(t) 60 61 err := applications.Delete(client.ServiceClient(), "c5faacb524d148b59ddd448dd02d016a", 62 "50f768cf1c1f4389965aa58d255b2a65").ExtractErr() 63 th.AssertNoErr(t, err) 64 } 65 66 func TestAddV2ApplicationCode(t *testing.T) { 67 th.SetupHTTP() 68 defer th.TeardownHTTP() 69 handleV2ApplicationCodeAdd(t) 70 71 actual, err := applications.CreateAppCode(client.ServiceClient(), "c5faacb524d148b59ddd448dd02d016a", 72 "50f768cf1c1f4389965aa58d255b2a65", appCodeOpts).Extract() 73 th.AssertNoErr(t, err) 74 th.AssertDeepEquals(t, expectedAddCodeResponseData, actual) 75 } 76 77 func TestAutoGenerateV2ApplicationCode(t *testing.T) { 78 th.SetupHTTP() 79 defer th.TeardownHTTP() 80 handleV2ApplicationCodeAutoGenerate(t) 81 82 actual, err := applications.AutoGenerateAppCode(client.ServiceClient(), "c5faacb524d148b59ddd448dd02d016a", 83 "50f768cf1c1f4389965aa58d255b2a65").Extract() 84 th.AssertNoErr(t, err) 85 th.AssertDeepEquals(t, expectedAddCodeResponseData, actual) 86 } 87 88 func TestGetV2ApplicationCode(t *testing.T) { 89 th.SetupHTTP() 90 defer th.TeardownHTTP() 91 handleV2ApplicationCodeGet(t) 92 93 actual, err := applications.GetAppCode(client.ServiceClient(), "c5faacb524d148b59ddd448dd02d016a", 94 "50f768cf1c1f4389965aa58d255b2a65", "f284119e19f34d4caead4dd94114a7f4").Extract() 95 th.AssertNoErr(t, err) 96 th.AssertDeepEquals(t, expectedAddCodeResponseData, actual) 97 } 98 99 func TestListV2ApplicationCode(t *testing.T) { 100 th.SetupHTTP() 101 defer th.TeardownHTTP() 102 handleV2ApplicationCodeList(t) 103 104 pages, err := applications.ListAppCode(client.ServiceClient(), "c5faacb524d148b59ddd448dd02d016a", 105 "50f768cf1c1f4389965aa58d255b2a65", applications.ListCodeOpts{}).AllPages() 106 th.AssertNoErr(t, err) 107 actual, err := applications.ExtractAppCodes(pages) 108 th.AssertNoErr(t, err) 109 th.AssertDeepEquals(t, expectedListCodeResponseData, actual) 110 } 111 112 func TestRemove2ApplicationCode(t *testing.T) { 113 th.SetupHTTP() 114 defer th.TeardownHTTP() 115 handleV2ApplicationCodeRemove(t) 116 117 err := applications.RemoveAppCode(client.ServiceClient(), "c5faacb524d148b59ddd448dd02d016a", 118 "50f768cf1c1f4389965aa58d255b2a65", "f284119e19f34d4caead4dd94114a7f4").ExtractErr() 119 th.AssertNoErr(t, err) 120 }