70 lines
1.6 KiB
Go
70 lines
1.6 KiB
Go
// Code generated by moq; DO NOT EDIT.
|
|
// github.com/matryer/moq
|
|
|
|
package codespace
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
// prompterMock is a mock implementation of prompter.
|
|
//
|
|
// func TestSomethingThatUsesprompter(t *testing.T) {
|
|
//
|
|
// // make and configure a mocked prompter
|
|
// mockedprompter := &prompterMock{
|
|
// ConfirmFunc: func(message string) (bool, error) {
|
|
// panic("mock out the Confirm method")
|
|
// },
|
|
// }
|
|
//
|
|
// // use mockedprompter in code that requires prompter
|
|
// // and then make assertions.
|
|
//
|
|
// }
|
|
type prompterMock struct {
|
|
// ConfirmFunc mocks the Confirm method.
|
|
ConfirmFunc func(message string) (bool, error)
|
|
|
|
// calls tracks calls to the methods.
|
|
calls struct {
|
|
// Confirm holds details about calls to the Confirm method.
|
|
Confirm []struct {
|
|
// Message is the message argument value.
|
|
Message string
|
|
}
|
|
}
|
|
lockConfirm sync.RWMutex
|
|
}
|
|
|
|
// Confirm calls ConfirmFunc.
|
|
func (mock *prompterMock) Confirm(message string) (bool, error) {
|
|
if mock.ConfirmFunc == nil {
|
|
panic("prompterMock.ConfirmFunc: method is nil but prompter.Confirm was just called")
|
|
}
|
|
callInfo := struct {
|
|
Message string
|
|
}{
|
|
Message: message,
|
|
}
|
|
mock.lockConfirm.Lock()
|
|
mock.calls.Confirm = append(mock.calls.Confirm, callInfo)
|
|
mock.lockConfirm.Unlock()
|
|
return mock.ConfirmFunc(message)
|
|
}
|
|
|
|
// ConfirmCalls gets all the calls that were made to Confirm.
|
|
// Check the length with:
|
|
//
|
|
// len(mockedprompter.ConfirmCalls())
|
|
func (mock *prompterMock) ConfirmCalls() []struct {
|
|
Message string
|
|
} {
|
|
var calls []struct {
|
|
Message string
|
|
}
|
|
mock.lockConfirm.RLock()
|
|
calls = mock.calls.Confirm
|
|
mock.lockConfirm.RUnlock()
|
|
return calls
|
|
}
|