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 53 54 55 56 57 58 59 60
|
package testing
import (
"testing"
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/evacuate"
th "github.com/gophercloud/gophercloud/testhelper"
"github.com/gophercloud/gophercloud/testhelper/client"
)
func TestEvacuate(t *testing.T) {
const serverID = "b16ba811-199d-4ffd-8839-ba96c1185a67"
th.SetupHTTP()
defer th.TeardownHTTP()
mockEvacuateResponse(t, serverID)
_, err := evacuate.Evacuate(client.ServiceClient(), serverID, evacuate.EvacuateOpts{
Host: "derp",
AdminPass: "MySecretPass",
OnSharedStorage: false,
}).ExtractAdminPass()
th.AssertNoErr(t, err)
}
func TestEvacuateWithHost(t *testing.T) {
const serverID = "b16ba811-199d-4ffd-8839-ba96c1185a67"
th.SetupHTTP()
defer th.TeardownHTTP()
mockEvacuateResponseWithHost(t, serverID)
_, err := evacuate.Evacuate(client.ServiceClient(), serverID, evacuate.EvacuateOpts{
Host: "derp",
}).ExtractAdminPass()
th.AssertNoErr(t, err)
}
func TestEvacuateWithNoOpts(t *testing.T) {
const serverID = "b16ba811-199d-4ffd-8839-ba96c1185a67"
th.SetupHTTP()
defer th.TeardownHTTP()
mockEvacuateResponseWithNoOpts(t, serverID)
_, err := evacuate.Evacuate(client.ServiceClient(), serverID, evacuate.EvacuateOpts{}).ExtractAdminPass()
th.AssertNoErr(t, err)
}
func TestEvacuateAdminpassResponse(t *testing.T) {
const serverID = "b16ba811-199d-4ffd-8839-ba96c1185a67"
th.SetupHTTP()
defer th.TeardownHTTP()
mockEvacuateAdminpassResponse(t, serverID)
actual, err := evacuate.Evacuate(client.ServiceClient(), serverID, evacuate.EvacuateOpts{}).ExtractAdminPass()
th.CheckEquals(t, "MySecretPass", actual)
th.AssertNoErr(t, err)
}
|