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
|
package testing
import (
"testing"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/instanceactions"
"github.com/gophercloud/gophercloud/pagination"
th "github.com/gophercloud/gophercloud/testhelper"
"github.com/gophercloud/gophercloud/testhelper/client"
)
func TestList(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleInstanceActionListSuccessfully(t)
expected := ListExpected
pages := 0
err := instanceactions.List(client.ServiceClient(), "asdfasdfasdf", nil).EachPage(func(page pagination.Page) (bool, error) {
pages++
actual, err := instanceactions.ExtractInstanceActions(page)
th.AssertNoErr(t, err)
if len(actual) != 2 {
t.Fatalf("Expected 2 instance actions, got %d", len(actual))
}
th.CheckDeepEquals(t, expected, actual)
return true, nil
})
th.AssertNoErr(t, err)
th.CheckEquals(t, 1, pages)
}
func TestGet(t *testing.T) {
th.SetupHTTP()
defer th.TeardownHTTP()
HandleInstanceActionGetSuccessfully(t)
client := client.ServiceClient()
actual, err := instanceactions.Get(client, "asdfasdfasdf", "okzeorkmkfs").Extract()
if err != nil {
t.Fatalf("Unexpected Get error: %v", err)
}
th.CheckDeepEquals(t, GetExpected, actual)
}
|