github.com/sneal/packer@v0.5.2/builder/vmware/common/driver_mock.go (about) 1 package common 2 3 import ( 4 "sync" 5 6 "github.com/mitchellh/multistep" 7 ) 8 9 type DriverMock struct { 10 sync.Mutex 11 12 CloneCalled bool 13 CloneDst string 14 CloneSrc string 15 CloneErr error 16 17 CompactDiskCalled bool 18 CompactDiskPath string 19 CompactDiskErr error 20 21 CreateDiskCalled bool 22 CreateDiskOutput string 23 CreateDiskSize string 24 CreateDiskTypeId string 25 CreateDiskErr error 26 27 IsRunningCalled bool 28 IsRunningPath string 29 IsRunningResult bool 30 IsRunningErr error 31 32 SSHAddressCalled bool 33 SSHAddressState multistep.StateBag 34 SSHAddressResult string 35 SSHAddressErr error 36 37 StartCalled bool 38 StartPath string 39 StartHeadless bool 40 StartErr error 41 42 StopCalled bool 43 StopPath string 44 StopErr error 45 46 SuppressMessagesCalled bool 47 SuppressMessagesPath string 48 SuppressMessagesErr error 49 50 ToolsIsoPathCalled bool 51 ToolsIsoPathFlavor string 52 ToolsIsoPathResult string 53 54 DhcpLeasesPathCalled bool 55 DhcpLeasesPathDevice string 56 DhcpLeasesPathResult string 57 58 VerifyCalled bool 59 VerifyErr error 60 } 61 62 func (d *DriverMock) Clone(dst string, src string) error { 63 d.CloneCalled = true 64 d.CloneDst = dst 65 d.CloneSrc = src 66 return d.CloneErr 67 } 68 69 func (d *DriverMock) CompactDisk(path string) error { 70 d.CompactDiskCalled = true 71 d.CompactDiskPath = path 72 return d.CompactDiskErr 73 } 74 75 func (d *DriverMock) CreateDisk(output string, size string, typeId string) error { 76 d.CreateDiskCalled = true 77 d.CreateDiskOutput = output 78 d.CreateDiskSize = size 79 d.CreateDiskTypeId = typeId 80 return d.CreateDiskErr 81 } 82 83 func (d *DriverMock) IsRunning(path string) (bool, error) { 84 d.Lock() 85 defer d.Unlock() 86 87 d.IsRunningCalled = true 88 d.IsRunningPath = path 89 return d.IsRunningResult, d.IsRunningErr 90 } 91 92 func (d *DriverMock) SSHAddress(state multistep.StateBag) (string, error) { 93 d.SSHAddressCalled = true 94 d.SSHAddressState = state 95 return d.SSHAddressResult, d.SSHAddressErr 96 } 97 98 func (d *DriverMock) Start(path string, headless bool) error { 99 d.StartCalled = true 100 d.StartPath = path 101 d.StartHeadless = headless 102 return d.StartErr 103 } 104 105 func (d *DriverMock) Stop(path string) error { 106 d.StopCalled = true 107 d.StopPath = path 108 return d.StopErr 109 } 110 111 func (d *DriverMock) SuppressMessages(path string) error { 112 d.SuppressMessagesCalled = true 113 d.SuppressMessagesPath = path 114 return d.SuppressMessagesErr 115 } 116 117 func (d *DriverMock) ToolsIsoPath(flavor string) string { 118 d.ToolsIsoPathCalled = true 119 d.ToolsIsoPathFlavor = flavor 120 return d.ToolsIsoPathResult 121 } 122 123 func (d *DriverMock) DhcpLeasesPath(device string) string { 124 d.DhcpLeasesPathCalled = true 125 d.DhcpLeasesPathDevice = device 126 return d.DhcpLeasesPathResult 127 } 128 129 func (d *DriverMock) Verify() error { 130 d.VerifyCalled = true 131 return d.VerifyErr 132 }