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-08-31 02:21:15 -04:00
|
|
|
PrepCalled bool
|
|
|
|
PrepConfigs []interface{}
|
|
|
|
ProvCalled bool
|
|
|
|
ProvUi Ui
|
|
|
|
CancelCalled bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MockProvisioner) Prepare(configs ...interface{}) error {
|
|
|
|
t.PrepCalled = true
|
|
|
|
t.PrepConfigs = configs
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MockProvisioner) Provision(ui Ui, comm Communicator) error {
|
|
|
|
t.ProvCalled = true
|
|
|
|
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
|
|
|
|
}
|