packer-cn/packer/hook_mock.go

32 lines
531 B
Go
Raw Normal View History

2013-08-30 20:03:55 -04:00
package packer
import (
"context"
)
2013-08-30 20:03:55 -04:00
// MockHook is an implementation of Hook that can be used for tests.
type MockHook struct {
RunFunc func(context.Context) error
2013-08-31 02:10:16 -04:00
RunCalled bool
RunComm Communicator
RunData interface{}
RunName string
RunUi Ui
2013-08-30 20:03:55 -04:00
}
func (t *MockHook) Run(ctx context.Context, name string, ui Ui, comm Communicator, data interface{}) error {
2013-08-30 20:03:55 -04:00
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(ctx)
2013-08-30 20:03:55 -04:00
}