Added missing functions to builder\virtualbox\common\driver_mock.go

This commit is contained in:
Thomas Meckel 2019-06-26 16:06:37 +02:00 committed by Thomas Meckel
parent fd5a2db58f
commit e9b5332e99
1 changed files with 73 additions and 0 deletions

View File

@ -45,6 +45,17 @@ type DriverMock struct {
VersionCalled bool VersionCalled bool
VersionResult string VersionResult string
VersionErr error VersionErr error
LoadSnapshotsCalled []string
LoadSnapshotsResult *VBoxSnapshot
CreateSnapshotCalled []string
CreateSnapshotError error
HasSnapshotsCalled []string
HasSnapshotsResult bool
GetCurrentSnapshotCalled []string
GetCurrentSnapshotResult *VBoxSnapshot
SetSnapshotCalled []*VBoxSnapshot
DeleteSnapshotCalled []*VBoxSnapshot
} }
func (d *DriverMock) CreateSATAController(vm string, controller string, portcount int) error { func (d *DriverMock) CreateSATAController(vm string, controller string, portcount int) error {
@ -114,3 +125,65 @@ func (d *DriverMock) Version() (string, error) {
d.VersionCalled = true d.VersionCalled = true
return d.VersionResult, d.VersionErr return d.VersionResult, d.VersionErr
} }
func (d *DriverMock) LoadSnapshots(string vmName) (*VBoxSnapshot, error) {
if vmName == "" {
panic("Argument empty exception: vmName")
}
d.LoadSnapshotsCalled = append(d.LoadSnapshotsCalled, vmName)
return d.LoadSnapshotsResult, nil
}
func (d *DriverMock) CreateSnapshot(string vmName, string snapshotName) error {
if vmName == "" {
panic("Argument empty exception: vmName")
}
if snapshotName == "" {
panic("Argument empty exception: snapshotName")
}
d.CreateSnapshotCalled = append(d.CreateSnapshotCalled, snapshotName)
return d.CreateSnapshotError
}
func (d *DriverMock) HasSnapshots(string vmName) (bool, error) {
if vmName == "" {
panic("Argument empty exception: vmName")
}
d.HasSnapshotsCalled = append(d.HasSnapshotsCalled, vmName)
return d.HasSnapshotsResult, nil
}
func (d *DriverMock) GetCurrentSnapshot(string vmName) (*VBoxSnapshot, error) {
if vmName == "" {
panic("Argument empty exception: vmName")
}
d.GetCurrentSnapshotCalled = append(d.GetCurrentSnapshotCalled, vmName)
return d.GetCurrentSnapshotResult, nil
}
func (d *DriverMock) SetSnapshot(string vmName, *VBoxSnapshot snapshot) error {
if vmName == "" {
panic("Argument empty exception: vmName")
}
if snapshot == nil {
panic("Argument empty exception: snapshot")
}
d.SetSnapshotCalled = append(d.SetSnapshotCalled, snapshot)
return nil
}
func (d *DriverMock) DeleteSnapshot(string vmName, *VBoxSnapshot snapshot) error {
if vmName == "" {
panic("Argument empty exception: vmName")
}
if snapshot == nil {
panic("Argument empty exception: snapshot")
}
d.DeleteSnapshotCalled = append(d.DeleteSnapshotCalled, snapshot)
return nil
}