2013-08-31 02:21:15 -04:00
|
|
|
package packer
|
|
|
|
|
|
|
|
// MockProvisioner is an implementation of Provisioner that can be
|
|
|
|
// used for tests.
|
|
|
|
type MockProvisioner struct {
|
2013-08-31 02:39:29 -04:00
|
|
|
ProvFunc func() error
|
|
|
|
|
2013-12-21 00:36:41 -05:00
|
|
|
PrepCalled bool
|
|
|
|
PrepConfigs []interface{}
|
|
|
|
ProvCalled bool
|
|
|
|
ProvCommunicator Communicator
|
|
|
|
ProvUi Ui
|
|
|
|
CancelCalled bool
|
2013-08-31 02:21:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MockProvisioner) Prepare(configs ...interface{}) error {
|
2018-09-10 19:48:42 -04:00
|
|
|
t.PrepCalled = true
|
|
|
|
t.PrepConfigs = configs
|
2013-08-31 02:21:15 -04:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MockProvisioner) Provision(ui Ui, comm Communicator) error {
|
|
|
|
t.ProvCalled = true
|
2013-12-21 00:36:41 -05:00
|
|
|
t.ProvCommunicator = comm
|
2013-08-31 02:21:15 -04:00
|
|
|
t.ProvUi = ui
|
2013-08-31 02:39:29 -04:00
|
|
|
|
|
|
|
if t.ProvFunc == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return t.ProvFunc()
|
2013-08-31 02:21:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MockProvisioner) Cancel() {
|
|
|
|
t.CancelCalled = true
|
|
|
|
}
|