github.com/gophercloud/gophercloud@v1.11.0/internal/acceptance/openstack/loadbalancer/v2/flavorprofiles_test.go (about)

     1  //go:build acceptance || networking || loadbalancer || flavorprofiles
     2  // +build acceptance networking loadbalancer flavorprofiles
     3  
     4  package v2
     5  
     6  import (
     7  	"testing"
     8  
     9  	"github.com/gophercloud/gophercloud/internal/acceptance/clients"
    10  	"github.com/gophercloud/gophercloud/internal/acceptance/tools"
    11  	"github.com/gophercloud/gophercloud/openstack/loadbalancer/v2/flavorprofiles"
    12  
    13  	th "github.com/gophercloud/gophercloud/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()
    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(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  }