2013-08-30 20:03:55 -04:00
|
|
|
package packer
|
|
|
|
|
|
|
|
// MockHook is an implementation of Hook that can be used for tests.
|
|
|
|
type MockHook struct {
|
2013-08-31 02:10:16 -04:00
|
|
|
RunFunc func() error
|
|
|
|
|
2013-08-30 20:03:55 -04:00
|
|
|
RunCalled bool
|
|
|
|
RunComm Communicator
|
|
|
|
RunData interface{}
|
|
|
|
RunName string
|
|
|
|
RunUi Ui
|
|
|
|
CancelCalled bool
|
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MockHook) Run(name string, ui Ui, comm Communicator, data interface{}) error {
|
|
|
|
t.RunCalled = true
|
|
|
|
t.RunComm = comm
|
|
|
|
t.RunData = data
|
|
|
|
t.RunName = name
|
|
|
|
t.RunUi = ui
|
2013-08-31 02:10:16 -04:00
|
|
|
|
|
|
|
if t.RunFunc == nil {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return t.RunFunc()
|
2013-08-30 20:03:55 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
func (t *MockHook) Cancel() {
|
|
|
|
t.CancelCalled = true
|
|
|
|
}
|