1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
// +build acceptance clustering policies
package v1
import (
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
"github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/clustering/v1/profiles"
th "github.com/gophercloud/gophercloud/testhelper"
)
func TestProfilesCRUD(t *testing.T) {
client, err := clients.NewClusteringV1Client()
th.AssertNoErr(t, err)
profile, err := CreateProfile(t, client)
th.AssertNoErr(t, err)
defer DeleteProfile(t, client, profile.ID)
// Test listing profiles
allPages, err := profiles.List(client, nil).AllPages()
th.AssertNoErr(t, err)
allProfiles, err := profiles.ExtractProfiles(allPages)
th.AssertNoErr(t, err)
var found bool
for _, v := range allProfiles {
if v.ID == profile.ID {
found = true
}
}
th.AssertEquals(t, found, true)
// Test updating profile
updateOpts := profiles.UpdateOpts{
Name: profile.Name + "-UPDATED",
}
newProfile, err := profiles.Update(client, profile.ID, updateOpts).Extract()
th.AssertNoErr(t, err)
th.AssertEquals(t, newProfile.Name, profile.Name+"-UPDATED")
tools.PrintResource(t, newProfile)
tools.PrintResource(t, newProfile.UpdatedAt)
}
|