1// +build acceptance baremetal allocations 2 3package noauth 4 5import ( 6 "testing" 7 8 "github.com/gophercloud/gophercloud/acceptance/clients" 9 v1 "github.com/gophercloud/gophercloud/acceptance/openstack/baremetal/v1" 10 "github.com/gophercloud/gophercloud/openstack/baremetal/v1/allocations" 11 "github.com/gophercloud/gophercloud/pagination" 12 th "github.com/gophercloud/gophercloud/testhelper" 13) 14 15func TestAllocationsCreateDestroy(t *testing.T) { 16 clients.RequireLong(t) 17 18 client, err := clients.NewBareMetalV1NoAuthClient() 19 th.AssertNoErr(t, err) 20 21 client.Microversion = "1.52" 22 23 allocation, err := v1.CreateAllocation(t, client) 24 th.AssertNoErr(t, err) 25 defer v1.DeleteAllocation(t, client, allocation) 26 27 found := false 28 err = allocations.List(client, allocations.ListOpts{}).EachPage(func(page pagination.Page) (bool, error) { 29 allocationList, err := allocations.ExtractAllocations(page) 30 if err != nil { 31 return false, err 32 } 33 34 for _, a := range allocationList { 35 if a.UUID == allocation.UUID { 36 found = true 37 return true, nil 38 } 39 } 40 41 return false, nil 42 }) 43 th.AssertNoErr(t, err) 44 th.AssertEquals(t, found, true) 45} 46