github.com/askholme/packer@v0.7.2-0.20140924152349-70d9566a6852/packer/provisioner_mock.go (about) 1 package packer 2 3 // MockProvisioner is an implementation of Provisioner that can be 4 // used for tests. 5 type MockProvisioner struct { 6 ProvFunc func() error 7 8 PrepCalled bool 9 PrepConfigs []interface{} 10 ProvCalled bool 11 ProvCommunicator Communicator 12 ProvUi Ui 13 CancelCalled bool 14 } 15 16 func (t *MockProvisioner) Prepare(configs ...interface{}) error { 17 t.PrepCalled = true 18 t.PrepConfigs = configs 19 return nil 20 } 21 22 func (t *MockProvisioner) Provision(ui Ui, comm Communicator) error { 23 t.ProvCalled = true 24 t.ProvCommunicator = comm 25 t.ProvUi = ui 26 27 if t.ProvFunc == nil { 28 return nil 29 } 30 31 return t.ProvFunc() 32 } 33 34 func (t *MockProvisioner) Cancel() { 35 t.CancelCalled = true 36 }