Remove pointer fixing panic on interface conversion

This commit is contained in:
Moss 2019-12-19 13:30:54 +01:00
parent 9eda2031d2
commit 42cf9ef064
3 changed files with 19 additions and 6 deletions

View File

@ -185,7 +185,7 @@ func (d *VBox42Driver) VBoxManage(args ...string) error {
ShouldRetry: func(err error) bool {
return strings.Contains(err.Error(), "VBOX_E_INVALID_OBJECT_STATE")
},
RetryDelay: func() time.Duration { return 2 * time.Minute },
RetryDelay: func() time.Duration { return 1 * time.Minute },
}.Run(ctx, func(ctx context.Context) error {
_, err := d.VBoxManageWithOutput(args...)
return err

View File

@ -42,7 +42,7 @@ func (s *StepImport) Cleanup(state multistep.StateBag) {
driver := state.Get("driver").(vboxcommon.Driver)
ui := state.Get("ui").(packer.Ui)
config := state.Get("config").(*Config)
config := state.Get("config").(Config)
_, cancelled := state.GetOk(multistep.StateCancelled)
_, halted := state.GetOk(multistep.StateHalted)

View File

@ -18,7 +18,7 @@ func TestStepImport(t *testing.T) {
var c Config
c.Prepare(cfg)
state.Put("vm_path", "foo")
state.Put("config", &c)
state.Put("config", c)
step := new(StepImport)
step.Name = "bar"
@ -46,16 +46,29 @@ func TestStepImport(t *testing.T) {
} else if name != "bar" {
t.Fatalf("bad: %#v", name)
}
}
func TestStepImport_Cleanup(t *testing.T) {
state := testState(t)
state.Put("vm_path", "foo")
cfg := testConfig(t)
var c Config
c.Prepare(cfg)
step := new(StepImport)
step.vmName = "bar"
driver := state.Get("driver").(*vboxcommon.DriverMock)
// Test cleanup
c.KeepRegistered = true
state.Put("config", c)
step.Cleanup(state)
if driver.DeleteCalled {
t.Fatal("delete should not be called")
}
c.KeepRegistered = false
state.Put(multistep.StateHalted, true)
step.Cleanup(state)
if !driver.DeleteCalled {
t.Fatal("delete should be called")