github.com/sneal/packer@v0.5.2/builder/virtualbox/common/step_export_test.go (about) 1 package common 2 3 import ( 4 "github.com/mitchellh/multistep" 5 "testing" 6 ) 7 8 func TestStepExport_impl(t *testing.T) { 9 var _ multistep.Step = new(StepExport) 10 } 11 12 func TestStepExport(t *testing.T) { 13 state := testState(t) 14 step := new(StepExport) 15 16 state.Put("vmName", "foo") 17 18 driver := state.Get("driver").(*DriverMock) 19 20 // Test the run 21 if action := step.Run(state); action != multistep.ActionContinue { 22 t.Fatalf("bad action: %#v", action) 23 } 24 if _, ok := state.GetOk("error"); ok { 25 t.Fatal("should NOT have error") 26 } 27 28 // Test output state 29 if _, ok := state.GetOk("exportPath"); !ok { 30 t.Fatal("should set exportPath") 31 } 32 33 // Test driver 34 if len(driver.VBoxManageCalls) != 2 { 35 t.Fatal("should call vboxmanage") 36 } 37 if driver.VBoxManageCalls[0][0] != "modifyvm" { 38 t.Fatal("bad") 39 } 40 if driver.VBoxManageCalls[1][0] != "export" { 41 t.Fatal("bad") 42 } 43 }