github.com/askholme/packer@v0.7.2-0.20140924152349-70d9566a6852/packer/hook_mock.go (about) 1 package packer 2 3 // MockHook is an implementation of Hook that can be used for tests. 4 type MockHook struct { 5 RunFunc func() error 6 7 RunCalled bool 8 RunComm Communicator 9 RunData interface{} 10 RunName string 11 RunUi Ui 12 CancelCalled bool 13 } 14 15 func (t *MockHook) Run(name string, ui Ui, comm Communicator, data interface{}) error { 16 t.RunCalled = true 17 t.RunComm = comm 18 t.RunData = data 19 t.RunName = name 20 t.RunUi = ui 21 22 if t.RunFunc == nil { 23 return nil 24 } 25 26 return t.RunFunc() 27 } 28 29 func (t *MockHook) Cancel() { 30 t.CancelCalled = true 31 }