github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/vpc/v1/publicips/testing/requests_test.go (about) 1 package testing 2 3 import ( 4 "testing" 5 6 "github.com/huaweicloud/golangsdk/openstack/vpc/v1/publicips" 7 th "github.com/huaweicloud/golangsdk/testhelper" 8 "github.com/huaweicloud/golangsdk/testhelper/client" 9 ) 10 11 func TestCreate(t *testing.T) { 12 th.SetupHTTP() 13 defer th.TeardownHTTP() 14 HandleCreateSuccessfully(t) 15 16 result, err := publicips.Create(client.ServiceClient(), publicips.CreateOpts{ 17 Publicip: publicips.PublicIPRequest{ 18 Type: "5_bgp", 19 }, 20 Bandwidth: publicips.BandWidth{ 21 Name: "bandwidth-d62f", 22 Size: 1, 23 ShareType: "WHOLE", 24 ChargeMode: "traffic"}, 25 }).Extract() 26 th.AssertNoErr(t, err) 27 th.CheckDeepEquals(t, &CreateResponse, result) 28 } 29 30 func TestUpdate(t *testing.T) { 31 th.SetupHTTP() 32 defer th.TeardownHTTP() 33 HandleUpdateSuccessfully(t) 34 35 actual, err := publicips.Update(client.ServiceClient(), "84a71976-a8c2-42e0-8826-7fc27b876e42", publicips.UpdateOpts{ 36 IPVersion: 4, 37 }).Extract() 38 th.AssertNoErr(t, err) 39 th.CheckDeepEquals(t, &UpdateResponse, actual) 40 } 41 42 func TestGet(t *testing.T) { 43 th.SetupHTTP() 44 defer th.TeardownHTTP() 45 HandleGetSuccessfully(t) 46 47 actual, err := publicips.Get(client.ServiceClient(), "84a71976-a8c2-42e0-8826-7fc27b876e42").Extract() 48 th.AssertNoErr(t, err) 49 th.CheckDeepEquals(t, &GetResponse, actual) 50 } 51 52 func TestList(t *testing.T) { 53 th.SetupHTTP() 54 defer th.TeardownHTTP() 55 HandleListSuccessfully(t) 56 57 allpages, err := publicips.List(client.ServiceClient(), publicips.ListOpts{ 58 Limit: 2, 59 }).AllPages() 60 th.AssertNoErr(t, err) 61 publicipList, err := publicips.ExtractPublicIPs(allpages) 62 th.CheckDeepEquals(t, ListResponse, publicipList) 63 } 64 65 func TestDelete(t *testing.T) { 66 th.SetupHTTP() 67 defer th.TeardownHTTP() 68 HandleDeleteSuccessfully(t) 69 70 publicips.Delete(client.ServiceClient(), "7ffddb5f-6731-43d8-9476-1444aaa40bc0") 71 }