github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/compute/v2/extensions/evacuate/testing/requests_test.go (about) 1 package testing 2 3 import ( 4 "testing" 5 6 "github.com/huaweicloud/golangsdk/openstack/compute/v2/extensions/evacuate" 7 th "github.com/huaweicloud/golangsdk/testhelper" 8 "github.com/huaweicloud/golangsdk/testhelper/client" 9 ) 10 11 func TestEvacuate(t *testing.T) { 12 const serverID = "b16ba811-199d-4ffd-8839-ba96c1185a67" 13 th.SetupHTTP() 14 defer th.TeardownHTTP() 15 16 mockEvacuateResponse(t, serverID) 17 18 _, err := evacuate.Evacuate(client.ServiceClient(), serverID, evacuate.EvacuateOpts{ 19 Host: "derp", 20 AdminPass: "MySecretPass", 21 OnSharedStorage: false, 22 }).ExtractAdminPass() 23 th.AssertNoErr(t, err) 24 } 25 26 func TestEvacuateWithHost(t *testing.T) { 27 const serverID = "b16ba811-199d-4ffd-8839-ba96c1185a67" 28 th.SetupHTTP() 29 defer th.TeardownHTTP() 30 31 mockEvacuateResponseWithHost(t, serverID) 32 33 _, err := evacuate.Evacuate(client.ServiceClient(), serverID, evacuate.EvacuateOpts{ 34 Host: "derp", 35 }).ExtractAdminPass() 36 th.AssertNoErr(t, err) 37 } 38 39 func TestEvacuateWithNoOpts(t *testing.T) { 40 const serverID = "b16ba811-199d-4ffd-8839-ba96c1185a67" 41 th.SetupHTTP() 42 defer th.TeardownHTTP() 43 44 mockEvacuateResponseWithNoOpts(t, serverID) 45 46 _, err := evacuate.Evacuate(client.ServiceClient(), serverID, evacuate.EvacuateOpts{}).ExtractAdminPass() 47 th.AssertNoErr(t, err) 48 } 49 50 func TestEvacuateAdminpassResponse(t *testing.T) { 51 const serverID = "b16ba811-199d-4ffd-8839-ba96c1185a67" 52 th.SetupHTTP() 53 defer th.TeardownHTTP() 54 55 mockEvacuateAdminpassResponse(t, serverID) 56 57 actual, err := evacuate.Evacuate(client.ServiceClient(), serverID, evacuate.EvacuateOpts{}).ExtractAdminPass() 58 th.CheckEquals(t, "MySecretPass", actual) 59 th.AssertNoErr(t, err) 60 }