packer-cn/builder/virtualbox/common/step_export_test.go

46 lines
909 B
Go
Raw Normal View History

2013-12-22 13:40:39 -05:00
package common
import (
2018-01-22 19:03:49 -05:00
"context"
2013-12-22 13:40:39 -05:00
"testing"
2018-01-22 20:21:10 -05:00
"github.com/hashicorp/packer/helper/multistep"
2013-12-22 13:40:39 -05:00
)
func TestStepExport_impl(t *testing.T) {
var _ multistep.Step = new(StepExport)
}
func TestStepExport(t *testing.T) {
state := testState(t)
step := new(StepExport)
state.Put("vmName", "foo")
driver := state.Get("driver").(*DriverMock)
// Test the run
2018-01-22 19:03:49 -05:00
if action := step.Run(context.Background(), state); action != multistep.ActionContinue {
2013-12-22 13:40:39 -05:00
t.Fatalf("bad action: %#v", action)
}
if _, ok := state.GetOk("error"); ok {
t.Fatal("should NOT have error")
}
// Test output state
if _, ok := state.GetOk("exportPath"); !ok {
t.Fatal("should set exportPath")
}
// Test driver
if len(driver.VBoxManageCalls) != 2 {
t.Fatal("should call vboxmanage")
}
if driver.VBoxManageCalls[0][0] != "modifyvm" {
t.Fatal("bad")
}
if driver.VBoxManageCalls[1][0] != "export" {
t.Fatal("bad")
}
}