builder/vmware/common: more tests
This commit is contained in:
parent
7e991af48e
commit
ad72c5a4bb
|
@ -56,3 +56,60 @@ func TestStepPrepareTools(t *testing.T) {
|
|||
t.Fatalf("bad: %#v", path)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepPrepareTools_esx5(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := &StepPrepareTools{
|
||||
RemoteType: "esx5",
|
||||
ToolsUploadFlavor: "foo",
|
||||
}
|
||||
|
||||
driver := state.Get("driver").(*DriverMock)
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(state); action != multistep.ActionContinue {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); ok {
|
||||
t.Fatal("should NOT have error")
|
||||
}
|
||||
|
||||
// Test the driver
|
||||
if driver.ToolsIsoPathCalled {
|
||||
t.Fatal("tools iso path should NOT be called")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStepPrepareTools_nonExist(t *testing.T) {
|
||||
state := testState(t)
|
||||
step := &StepPrepareTools{
|
||||
RemoteType: "",
|
||||
ToolsUploadFlavor: "foo",
|
||||
}
|
||||
|
||||
driver := state.Get("driver").(*DriverMock)
|
||||
|
||||
// Mock results
|
||||
driver.ToolsIsoPathResult = "foo"
|
||||
|
||||
// Test the run
|
||||
if action := step.Run(state); action != multistep.ActionHalt {
|
||||
t.Fatalf("bad action: %#v", action)
|
||||
}
|
||||
if _, ok := state.GetOk("error"); !ok {
|
||||
t.Fatal("should have error")
|
||||
}
|
||||
|
||||
// Test the driver
|
||||
if !driver.ToolsIsoPathCalled {
|
||||
t.Fatal("tools iso path should be called")
|
||||
}
|
||||
if driver.ToolsIsoPathFlavor != "foo" {
|
||||
t.Fatalf("bad: %#v", driver.ToolsIsoPathFlavor)
|
||||
}
|
||||
|
||||
// Test the resulting state
|
||||
if _, ok := state.GetOk("tools_upload_source"); ok {
|
||||
t.Fatal("should NOT have tools_upload_source")
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue