github.com/sneal/packer@v0.5.2/builder/virtualbox/common/driver_mock.go (about) 1 package common 2 3 import "sync" 4 5 type DriverMock struct { 6 sync.Mutex 7 8 CreateSATAControllerVM string 9 CreateSATAControllerController string 10 CreateSATAControllerErr error 11 12 DeleteCalled bool 13 DeleteName string 14 DeleteErr error 15 16 ImportCalled bool 17 ImportName string 18 ImportPath string 19 ImportOpts string 20 ImportErr error 21 22 IsRunningName string 23 IsRunningReturn bool 24 IsRunningErr error 25 26 StopName string 27 StopErr error 28 29 SuppressMessagesCalled bool 30 SuppressMessagesErr error 31 32 VBoxManageCalls [][]string 33 VBoxManageErrs []error 34 35 VerifyCalled bool 36 VerifyErr error 37 38 VersionCalled bool 39 VersionResult string 40 VersionErr error 41 } 42 43 func (d *DriverMock) CreateSATAController(vm string, controller string) error { 44 d.CreateSATAControllerVM = vm 45 d.CreateSATAControllerController = vm 46 return d.CreateSATAControllerErr 47 } 48 49 func (d *DriverMock) Delete(name string) error { 50 d.DeleteCalled = true 51 d.DeleteName = name 52 return d.DeleteErr 53 } 54 55 func (d *DriverMock) Import(name, path, opts string) error { 56 d.ImportCalled = true 57 d.ImportName = name 58 d.ImportPath = path 59 d.ImportOpts = opts 60 return d.ImportErr 61 } 62 63 func (d *DriverMock) IsRunning(name string) (bool, error) { 64 d.Lock() 65 defer d.Unlock() 66 67 d.IsRunningName = name 68 return d.IsRunningReturn, d.IsRunningErr 69 } 70 71 func (d *DriverMock) Stop(name string) error { 72 d.StopName = name 73 return d.StopErr 74 } 75 76 func (d *DriverMock) SuppressMessages() error { 77 d.SuppressMessagesCalled = true 78 return d.SuppressMessagesErr 79 } 80 81 func (d *DriverMock) VBoxManage(args ...string) error { 82 d.VBoxManageCalls = append(d.VBoxManageCalls, args) 83 84 if len(d.VBoxManageErrs) >= len(d.VBoxManageCalls) { 85 return d.VBoxManageErrs[len(d.VBoxManageCalls)-1] 86 } 87 return nil 88 } 89 90 func (d *DriverMock) Verify() error { 91 d.VerifyCalled = true 92 return d.VerifyErr 93 } 94 95 func (d *DriverMock) Version() (string, error) { 96 d.VersionCalled = true 97 return d.VersionResult, d.VersionErr 98 }