github.com/vnpaycloud-console/gophercloud/v2@v2.0.5/internal/acceptance/openstack/loadbalancer/v2/flavorprofiles_test.go (about) 1 //go:build acceptance || networking || loadbalancer || flavorprofiles 2 3 package v2 4 5 import ( 6 "context" 7 "testing" 8 9 "github.com/vnpaycloud-console/gophercloud/v2/internal/acceptance/clients" 10 "github.com/vnpaycloud-console/gophercloud/v2/internal/acceptance/tools" 11 "github.com/vnpaycloud-console/gophercloud/v2/openstack/loadbalancer/v2/flavorprofiles" 12 13 th "github.com/vnpaycloud-console/gophercloud/v2/testhelper" 14 ) 15 16 func TestFlavorProfilesList(t *testing.T) { 17 client, err := clients.NewLoadBalancerV2Client() 18 th.AssertNoErr(t, err) 19 20 allPages, err := flavorprofiles.List(client, nil).AllPages(context.TODO()) 21 th.AssertNoErr(t, err) 22 23 allFlavorProfiles, err := flavorprofiles.ExtractFlavorProfiles(allPages) 24 th.AssertNoErr(t, err) 25 26 for _, flavorprofile := range allFlavorProfiles { 27 tools.PrintResource(t, flavorprofile) 28 } 29 } 30 31 func TestFlavorProfilesCRUD(t *testing.T) { 32 lbClient, err := clients.NewLoadBalancerV2Client() 33 th.AssertNoErr(t, err) 34 35 flavorProfile, err := CreateFlavorProfile(t, lbClient) 36 th.AssertNoErr(t, err) 37 defer DeleteFlavorProfile(t, lbClient, flavorProfile) 38 39 tools.PrintResource(t, flavorProfile) 40 41 th.AssertEquals(t, "amphora", flavorProfile.ProviderName) 42 43 flavorProfileUpdateOpts := flavorprofiles.UpdateOpts{ 44 Name: tools.RandomString("TESTACCTUP-", 8), 45 } 46 47 flavorProfileUpdated, err := flavorprofiles.Update(context.TODO(), lbClient, flavorProfile.ID, flavorProfileUpdateOpts).Extract() 48 th.AssertNoErr(t, err) 49 50 th.AssertEquals(t, flavorProfileUpdateOpts.Name, flavorProfileUpdated.Name) 51 52 t.Logf("Successfully updated flavorprofile %s", flavorProfileUpdated.Name) 53 }