github.com/bhameyie/otto@v0.2.1-0.20160406174117-16052efa52ec/ui/ui_mock.go (about) 1 package ui 2 3 // Mock is an implementation of Ui that stores its data in-memory 4 // primarily for testing purposes. 5 type Mock struct { 6 HeaderBuf []string 7 MessageBuf []string 8 RawBuf []string 9 10 InputCalled bool 11 InputOpts *InputOpts 12 InputResult string 13 InputError error 14 } 15 16 func (u *Mock) Header(msg string) { 17 u.HeaderBuf = append(u.HeaderBuf, msg) 18 } 19 20 func (u *Mock) Message(msg string) { 21 u.MessageBuf = append(u.MessageBuf, msg) 22 } 23 24 func (u *Mock) Raw(msg string) { 25 u.RawBuf = append(u.RawBuf, msg) 26 } 27 28 func (u *Mock) Input(opts *InputOpts) (string, error) { 29 u.InputCalled = true 30 u.InputOpts = opts 31 return u.InputResult, u.InputError 32 }