github.com/rothwerx/packer@v0.9.0/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  	CommHostCalled bool
    33  	CommHostState  multistep.StateBag
    34  	CommHostResult string
    35  	CommHostErr    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  	ToolsInstallCalled bool
    55  	ToolsInstallErr    error
    56  
    57  	DhcpLeasesPathCalled bool
    58  	DhcpLeasesPathDevice string
    59  	DhcpLeasesPathResult string
    60  
    61  	VerifyCalled bool
    62  	VerifyErr    error
    63  }
    64  
    65  func (d *DriverMock) Clone(dst string, src string) error {
    66  	d.CloneCalled = true
    67  	d.CloneDst = dst
    68  	d.CloneSrc = src
    69  	return d.CloneErr
    70  }
    71  
    72  func (d *DriverMock) CompactDisk(path string) error {
    73  	d.CompactDiskCalled = true
    74  	d.CompactDiskPath = path
    75  	return d.CompactDiskErr
    76  }
    77  
    78  func (d *DriverMock) CreateDisk(output string, size string, typeId string) error {
    79  	d.CreateDiskCalled = true
    80  	d.CreateDiskOutput = output
    81  	d.CreateDiskSize = size
    82  	d.CreateDiskTypeId = typeId
    83  	return d.CreateDiskErr
    84  }
    85  
    86  func (d *DriverMock) IsRunning(path string) (bool, error) {
    87  	d.Lock()
    88  	defer d.Unlock()
    89  
    90  	d.IsRunningCalled = true
    91  	d.IsRunningPath = path
    92  	return d.IsRunningResult, d.IsRunningErr
    93  }
    94  
    95  func (d *DriverMock) CommHost(state multistep.StateBag) (string, error) {
    96  	d.CommHostCalled = true
    97  	d.CommHostState = state
    98  	return d.CommHostResult, d.CommHostErr
    99  }
   100  
   101  func (d *DriverMock) Start(path string, headless bool) error {
   102  	d.StartCalled = true
   103  	d.StartPath = path
   104  	d.StartHeadless = headless
   105  	return d.StartErr
   106  }
   107  
   108  func (d *DriverMock) Stop(path string) error {
   109  	d.StopCalled = true
   110  	d.StopPath = path
   111  	return d.StopErr
   112  }
   113  
   114  func (d *DriverMock) SuppressMessages(path string) error {
   115  	d.SuppressMessagesCalled = true
   116  	d.SuppressMessagesPath = path
   117  	return d.SuppressMessagesErr
   118  }
   119  
   120  func (d *DriverMock) ToolsIsoPath(flavor string) string {
   121  	d.ToolsIsoPathCalled = true
   122  	d.ToolsIsoPathFlavor = flavor
   123  	return d.ToolsIsoPathResult
   124  }
   125  
   126  func (d *DriverMock) ToolsInstall() error {
   127  	d.ToolsInstallCalled = true
   128  	return d.ToolsInstallErr
   129  }
   130  
   131  func (d *DriverMock) DhcpLeasesPath(device string) string {
   132  	d.DhcpLeasesPathCalled = true
   133  	d.DhcpLeasesPathDevice = device
   134  	return d.DhcpLeasesPathResult
   135  }
   136  
   137  func (d *DriverMock) Verify() error {
   138  	d.VerifyCalled = true
   139  	return d.VerifyErr
   140  }