Documentation
¶
Index ¶
- func IndexFor(options []string, answer string) (int, error)
- func NoSuchAnswerErr(answer string) error
- func NoSuchPromptErr(prompt string) error
- type Prompter
- type PrompterMock
- func (mock *PrompterMock) AuthToken() (string, error)
- func (mock *PrompterMock) AuthTokenCalls() []struct{}
- func (mock *PrompterMock) Confirm(s string, b bool) (bool, error)
- func (mock *PrompterMock) ConfirmCalls() []struct{ ... }
- func (mock *PrompterMock) ConfirmDeletion(s string) error
- func (mock *PrompterMock) ConfirmDeletionCalls() []struct{ ... }
- func (mock *PrompterMock) Input(s1 string, s2 string) (string, error)
- func (mock *PrompterMock) InputCalls() []struct{ ... }
- func (mock *PrompterMock) InputHostname() (string, error)
- func (mock *PrompterMock) InputHostnameCalls() []struct{}
- func (mock *PrompterMock) MarkdownEditor(s1 string, s2 string, b bool) (string, error)
- func (mock *PrompterMock) MarkdownEditorCalls() []struct{ ... }
- func (mock *PrompterMock) MultiSelect(s1 string, s2 string, strings []string) (int, error)
- func (mock *PrompterMock) MultiSelectCalls() []struct{ ... }
- func (mock *PrompterMock) Password(s string) (string, error)
- func (mock *PrompterMock) PasswordCalls() []struct{ ... }
- func (mock *PrompterMock) Select(s1 string, s2 string, strings []string) (int, error)
- func (mock *PrompterMock) SelectCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NoSuchAnswerErr ¶
func NoSuchPromptErr ¶
Types ¶
type Prompter ¶
type Prompter interface { Select(string, string, []string) (int, error) MultiSelect(string, string, []string) (int, error) Input(string, string) (string, error) InputHostname() (string, error) Password(string) (string, error) AuthToken() (string, error) Confirm(string, bool) (bool, error) ConfirmDeletion(string) error MarkdownEditor(string, string, bool) (string, error) }
type PrompterMock ¶
type PrompterMock struct { // AuthTokenFunc mocks the AuthToken method. AuthTokenFunc func() (string, error) // ConfirmFunc mocks the Confirm method. ConfirmFunc func(s string, b bool) (bool, error) // ConfirmDeletionFunc mocks the ConfirmDeletion method. ConfirmDeletionFunc func(s string) error // InputFunc mocks the Input method. InputFunc func(s1 string, s2 string) (string, error) // InputHostnameFunc mocks the InputHostname method. InputHostnameFunc func() (string, error) // MarkdownEditorFunc mocks the MarkdownEditor method. MarkdownEditorFunc func(s1 string, s2 string, b bool) (string, error) // MultiSelectFunc mocks the MultiSelect method. MultiSelectFunc func(s1 string, s2 string, strings []string) (int, error) // PasswordFunc mocks the Password method. PasswordFunc func(s string) (string, error) // SelectFunc mocks the Select method. SelectFunc func(s1 string, s2 string, strings []string) (int, error) // contains filtered or unexported fields }
PrompterMock is a mock implementation of Prompter.
func TestSomethingThatUsesPrompter(t *testing.T) { // make and configure a mocked Prompter mockedPrompter := &PrompterMock{ AuthTokenFunc: func() (string, error) { panic("mock out the AuthToken method") }, ConfirmFunc: func(s string, b bool) (bool, error) { panic("mock out the Confirm method") }, ConfirmDeletionFunc: func(s string) error { panic("mock out the ConfirmDeletion method") }, InputFunc: func(s1 string, s2 string) (string, error) { panic("mock out the Input method") }, InputHostnameFunc: func() (string, error) { panic("mock out the InputHostname method") }, MarkdownEditorFunc: func(s1 string, s2 string, b bool) (string, error) { panic("mock out the MarkdownEditor method") }, MultiSelectFunc: func(s1 string, s2 string, strings []string) (int, error) { panic("mock out the MultiSelect method") }, PasswordFunc: func(s string) (string, error) { panic("mock out the Password method") }, SelectFunc: func(s1 string, s2 string, strings []string) (int, error) { panic("mock out the Select method") }, } // use mockedPrompter in code that requires Prompter // and then make assertions. }
func (*PrompterMock) AuthToken ¶
func (mock *PrompterMock) AuthToken() (string, error)
AuthToken calls AuthTokenFunc.
func (*PrompterMock) AuthTokenCalls ¶
func (mock *PrompterMock) AuthTokenCalls() []struct { }
AuthTokenCalls gets all the calls that were made to AuthToken. Check the length with:
len(mockedPrompter.AuthTokenCalls())
func (*PrompterMock) Confirm ¶
func (mock *PrompterMock) Confirm(s string, b bool) (bool, error)
Confirm calls ConfirmFunc.
func (*PrompterMock) ConfirmCalls ¶
func (mock *PrompterMock) ConfirmCalls() []struct { S string B bool }
ConfirmCalls gets all the calls that were made to Confirm. Check the length with:
len(mockedPrompter.ConfirmCalls())
func (*PrompterMock) ConfirmDeletion ¶ added in v2.17.0
func (mock *PrompterMock) ConfirmDeletion(s string) error
ConfirmDeletion calls ConfirmDeletionFunc.
func (*PrompterMock) ConfirmDeletionCalls ¶ added in v2.17.0
func (mock *PrompterMock) ConfirmDeletionCalls() []struct { S string }
ConfirmDeletionCalls gets all the calls that were made to ConfirmDeletion. Check the length with:
len(mockedPrompter.ConfirmDeletionCalls())
func (*PrompterMock) Input ¶
func (mock *PrompterMock) Input(s1 string, s2 string) (string, error)
Input calls InputFunc.
func (*PrompterMock) InputCalls ¶
func (mock *PrompterMock) InputCalls() []struct { S1 string S2 string }
InputCalls gets all the calls that were made to Input. Check the length with:
len(mockedPrompter.InputCalls())
func (*PrompterMock) InputHostname ¶
func (mock *PrompterMock) InputHostname() (string, error)
InputHostname calls InputHostnameFunc.
func (*PrompterMock) InputHostnameCalls ¶
func (mock *PrompterMock) InputHostnameCalls() []struct { }
InputHostnameCalls gets all the calls that were made to InputHostname. Check the length with:
len(mockedPrompter.InputHostnameCalls())
func (*PrompterMock) MarkdownEditor ¶
MarkdownEditor calls MarkdownEditorFunc.
func (*PrompterMock) MarkdownEditorCalls ¶
func (mock *PrompterMock) MarkdownEditorCalls() []struct { S1 string S2 string B bool }
MarkdownEditorCalls gets all the calls that were made to MarkdownEditor. Check the length with:
len(mockedPrompter.MarkdownEditorCalls())
func (*PrompterMock) MultiSelect ¶
MultiSelect calls MultiSelectFunc.
func (*PrompterMock) MultiSelectCalls ¶
func (mock *PrompterMock) MultiSelectCalls() []struct { S1 string S2 string Strings []string }
MultiSelectCalls gets all the calls that were made to MultiSelect. Check the length with:
len(mockedPrompter.MultiSelectCalls())
func (*PrompterMock) Password ¶
func (mock *PrompterMock) Password(s string) (string, error)
Password calls PasswordFunc.
func (*PrompterMock) PasswordCalls ¶
func (mock *PrompterMock) PasswordCalls() []struct { S string }
PasswordCalls gets all the calls that were made to Password. Check the length with:
len(mockedPrompter.PasswordCalls())
func (*PrompterMock) SelectCalls ¶
func (mock *PrompterMock) SelectCalls() []struct { S1 string S2 string Strings []string }
SelectCalls gets all the calls that were made to Select. Check the length with:
len(mockedPrompter.SelectCalls())