2013-12-21 19:04:41 -05:00
|
|
|
package common
|
|
|
|
|
2013-12-22 12:47:44 -05:00
|
|
|
import "sync"
|
|
|
|
|
2013-12-21 19:04:41 -05:00
|
|
|
type DriverMock struct {
|
2013-12-22 12:47:44 -05:00
|
|
|
sync.Mutex
|
|
|
|
|
2013-12-21 19:04:41 -05:00
|
|
|
CreateSATAControllerVM string
|
|
|
|
CreateSATAControllerController string
|
|
|
|
CreateSATAControllerErr error
|
|
|
|
|
2015-01-15 20:53:01 -05:00
|
|
|
CreateSCSIControllerVM string
|
|
|
|
CreateSCSIControllerController string
|
|
|
|
CreateSCSIControllerErr error
|
|
|
|
|
2013-12-22 18:19:19 -05:00
|
|
|
DeleteCalled bool
|
|
|
|
DeleteName string
|
|
|
|
DeleteErr error
|
|
|
|
|
|
|
|
ImportCalled bool
|
|
|
|
ImportName string
|
|
|
|
ImportPath string
|
2014-09-05 13:23:37 -04:00
|
|
|
ImportFlags []string
|
2013-12-22 18:19:19 -05:00
|
|
|
ImportErr error
|
|
|
|
|
2014-05-06 18:37:49 -04:00
|
|
|
IsoCalled bool
|
|
|
|
IsoErr error
|
|
|
|
|
2013-12-21 19:04:41 -05:00
|
|
|
IsRunningName string
|
|
|
|
IsRunningReturn bool
|
|
|
|
IsRunningErr error
|
|
|
|
|
|
|
|
StopName string
|
|
|
|
StopErr error
|
|
|
|
|
|
|
|
SuppressMessagesCalled bool
|
|
|
|
SuppressMessagesErr error
|
|
|
|
|
2013-12-22 11:10:11 -05:00
|
|
|
VBoxManageCalls [][]string
|
|
|
|
VBoxManageErrs []error
|
2013-12-21 19:04:41 -05:00
|
|
|
|
|
|
|
VerifyCalled bool
|
|
|
|
VerifyErr error
|
|
|
|
|
|
|
|
VersionCalled bool
|
|
|
|
VersionResult string
|
|
|
|
VersionErr error
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *DriverMock) CreateSATAController(vm string, controller string) error {
|
|
|
|
d.CreateSATAControllerVM = vm
|
|
|
|
d.CreateSATAControllerController = vm
|
|
|
|
return d.CreateSATAControllerErr
|
|
|
|
}
|
|
|
|
|
2015-01-15 20:53:01 -05:00
|
|
|
func (d *DriverMock) CreateSCSIController(vm string, controller string) error {
|
|
|
|
d.CreateSCSIControllerVM = vm
|
|
|
|
d.CreateSCSIControllerController = vm
|
|
|
|
return d.CreateSCSIControllerErr
|
|
|
|
}
|
|
|
|
|
2013-12-22 18:19:19 -05:00
|
|
|
func (d *DriverMock) Delete(name string) error {
|
|
|
|
d.DeleteCalled = true
|
|
|
|
d.DeleteName = name
|
|
|
|
return d.DeleteErr
|
|
|
|
}
|
|
|
|
|
2014-09-05 13:23:37 -04:00
|
|
|
func (d *DriverMock) Import(name string, path string, flags []string) error {
|
2013-12-22 18:19:19 -05:00
|
|
|
d.ImportCalled = true
|
|
|
|
d.ImportName = name
|
|
|
|
d.ImportPath = path
|
2014-09-05 13:23:37 -04:00
|
|
|
d.ImportFlags = flags
|
2013-12-22 18:19:19 -05:00
|
|
|
return d.ImportErr
|
|
|
|
}
|
|
|
|
|
2014-05-06 18:37:49 -04:00
|
|
|
func (d *DriverMock) Iso() (string, error) {
|
|
|
|
d.IsoCalled = true
|
|
|
|
return "", d.IsoErr
|
|
|
|
}
|
|
|
|
|
2013-12-21 19:04:41 -05:00
|
|
|
func (d *DriverMock) IsRunning(name string) (bool, error) {
|
2013-12-22 12:47:44 -05:00
|
|
|
d.Lock()
|
|
|
|
defer d.Unlock()
|
|
|
|
|
2013-12-21 19:04:41 -05:00
|
|
|
d.IsRunningName = name
|
|
|
|
return d.IsRunningReturn, d.IsRunningErr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *DriverMock) Stop(name string) error {
|
|
|
|
d.StopName = name
|
|
|
|
return d.StopErr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *DriverMock) SuppressMessages() error {
|
|
|
|
d.SuppressMessagesCalled = true
|
|
|
|
return d.SuppressMessagesErr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *DriverMock) VBoxManage(args ...string) error {
|
2013-12-22 11:10:11 -05:00
|
|
|
d.VBoxManageCalls = append(d.VBoxManageCalls, args)
|
|
|
|
|
|
|
|
if len(d.VBoxManageErrs) >= len(d.VBoxManageCalls) {
|
|
|
|
return d.VBoxManageErrs[len(d.VBoxManageCalls)-1]
|
|
|
|
}
|
|
|
|
return nil
|
2013-12-21 19:04:41 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
func (d *DriverMock) Verify() error {
|
|
|
|
d.VerifyCalled = true
|
|
|
|
return d.VerifyErr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *DriverMock) Version() (string, error) {
|
|
|
|
d.VersionCalled = true
|
|
|
|
return d.VersionResult, d.VersionErr
|
|
|
|
}
|