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 50 51 52
|
//go:build acceptance
// +build acceptance
package v1
import (
"testing"
"github.com/gophercloud/gophercloud/acceptance/clients"
"github.com/gophercloud/gophercloud/acceptance/tools"
"github.com/gophercloud/gophercloud/openstack/orchestration/v1/stacks"
th "github.com/gophercloud/gophercloud/testhelper"
)
func TestStacksCRUD(t *testing.T) {
client, err := clients.NewOrchestrationV1Client()
th.AssertNoErr(t, err)
createdStack, err := CreateStack(t, client)
th.AssertNoErr(t, err)
defer DeleteStack(t, client, createdStack.Name, createdStack.ID)
tools.PrintResource(t, createdStack)
tools.PrintResource(t, createdStack.CreationTime)
template := new(stacks.Template)
template.Bin = []byte(basicTemplate)
updateOpts := stacks.UpdateOpts{
TemplateOpts: template,
Timeout: 20,
}
err = stacks.Update(client, createdStack.Name, createdStack.ID, updateOpts).ExtractErr()
th.AssertNoErr(t, err)
err = WaitForStackStatus(client, createdStack.Name, createdStack.ID, "UPDATE_COMPLETE")
th.AssertNoErr(t, err)
var found bool
allPages, err := stacks.List(client, nil).AllPages()
th.AssertNoErr(t, err)
allStacks, err := stacks.ExtractStacks(allPages)
th.AssertNoErr(t, err)
for _, v := range allStacks {
if v.ID == createdStack.ID {
found = true
}
}
th.AssertEquals(t, found, true)
}
|