2014-04-06 13:21:22 -04:00
|
|
|
package common
|
|
|
|
|
|
|
|
import "sync"
|
|
|
|
|
|
|
|
type DriverMock struct {
|
|
|
|
sync.Mutex
|
|
|
|
|
2014-09-17 07:01:54 -04:00
|
|
|
DeviceAddCdRomCalled bool
|
|
|
|
DeviceAddCdRomName string
|
|
|
|
DeviceAddCdRomImage string
|
|
|
|
DeviceAddCdRomResult string
|
|
|
|
DeviceAddCdRomErr error
|
|
|
|
|
2014-04-06 13:21:22 -04:00
|
|
|
ImportCalled bool
|
|
|
|
ImportName string
|
|
|
|
ImportSrcPath string
|
|
|
|
ImportDstPath string
|
|
|
|
ImportErr error
|
|
|
|
|
|
|
|
IsRunningName string
|
|
|
|
IsRunningReturn bool
|
|
|
|
IsRunningErr error
|
|
|
|
|
|
|
|
StopName string
|
|
|
|
StopErr error
|
|
|
|
|
|
|
|
PrlctlCalls [][]string
|
|
|
|
PrlctlErrs []error
|
|
|
|
|
|
|
|
VerifyCalled bool
|
|
|
|
VerifyErr error
|
|
|
|
|
|
|
|
VersionCalled bool
|
|
|
|
VersionResult string
|
|
|
|
VersionErr error
|
|
|
|
|
|
|
|
SendKeyScanCodesCalls [][]string
|
|
|
|
SendKeyScanCodesErrs []error
|
|
|
|
|
2015-06-18 07:36:32 -04:00
|
|
|
SetDefaultConfigurationCalled bool
|
|
|
|
SetDefaultConfigurationError error
|
|
|
|
|
2014-08-22 05:06:55 -04:00
|
|
|
ToolsIsoPathCalled bool
|
|
|
|
ToolsIsoPathFlavor string
|
|
|
|
ToolsIsoPathResult string
|
|
|
|
ToolsIsoPathErr error
|
|
|
|
|
2014-04-06 13:21:22 -04:00
|
|
|
MacName string
|
|
|
|
MacReturn string
|
|
|
|
MacError error
|
|
|
|
|
|
|
|
IpAddressMac string
|
|
|
|
IpAddressReturn string
|
|
|
|
IpAddressError error
|
|
|
|
}
|
|
|
|
|
2014-09-17 07:01:54 -04:00
|
|
|
func (d *DriverMock) DeviceAddCdRom(name string, image string) (string, error) {
|
|
|
|
d.DeviceAddCdRomCalled = true
|
|
|
|
d.DeviceAddCdRomName = name
|
|
|
|
d.DeviceAddCdRomImage = image
|
|
|
|
return d.DeviceAddCdRomResult, d.DeviceAddCdRomErr
|
|
|
|
}
|
|
|
|
|
2014-08-12 08:52:27 -04:00
|
|
|
func (d *DriverMock) Import(name, srcPath, dstPath string, reassignMac bool) error {
|
2014-04-06 13:21:22 -04:00
|
|
|
d.ImportCalled = true
|
|
|
|
d.ImportName = name
|
|
|
|
d.ImportSrcPath = srcPath
|
|
|
|
d.ImportDstPath = dstPath
|
|
|
|
return d.ImportErr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *DriverMock) IsRunning(name string) (bool, error) {
|
|
|
|
d.Lock()
|
|
|
|
defer d.Unlock()
|
|
|
|
|
|
|
|
d.IsRunningName = name
|
|
|
|
return d.IsRunningReturn, d.IsRunningErr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *DriverMock) Stop(name string) error {
|
|
|
|
d.StopName = name
|
|
|
|
return d.StopErr
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *DriverMock) Prlctl(args ...string) error {
|
|
|
|
d.PrlctlCalls = append(d.PrlctlCalls, args)
|
|
|
|
|
|
|
|
if len(d.PrlctlErrs) >= len(d.PrlctlCalls) {
|
|
|
|
return d.PrlctlErrs[len(d.PrlctlCalls)-1]
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *DriverMock) SendKeyScanCodes(name string, scancodes ...string) error {
|
|
|
|
d.SendKeyScanCodesCalls = append(d.SendKeyScanCodesCalls, scancodes)
|
|
|
|
|
|
|
|
if len(d.SendKeyScanCodesErrs) >= len(d.SendKeyScanCodesCalls) {
|
|
|
|
return d.SendKeyScanCodesErrs[len(d.SendKeyScanCodesCalls)-1]
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2015-06-18 07:36:32 -04:00
|
|
|
func (d *DriverMock) SetDefaultConfiguration(name string) error {
|
|
|
|
d.SetDefaultConfigurationCalled = true
|
|
|
|
return d.SetDefaultConfigurationError
|
|
|
|
}
|
|
|
|
|
2014-04-06 13:21:22 -04:00
|
|
|
func (d *DriverMock) Mac(name string) (string, error) {
|
|
|
|
d.MacName = name
|
|
|
|
return d.MacReturn, d.MacError
|
|
|
|
}
|
|
|
|
|
|
|
|
func (d *DriverMock) IpAddress(mac string) (string, error) {
|
|
|
|
d.IpAddressMac = mac
|
|
|
|
return d.IpAddressReturn, d.IpAddressError
|
|
|
|
}
|
2014-08-22 05:06:55 -04:00
|
|
|
|
|
|
|
func (d *DriverMock) ToolsIsoPath(flavor string) (string, error) {
|
|
|
|
d.ToolsIsoPathCalled = true
|
|
|
|
d.ToolsIsoPathFlavor = flavor
|
|
|
|
return d.ToolsIsoPathResult, d.ToolsIsoPathErr
|
|
|
|
}
|