Add test for MultiSelectWithSearch error propagation
Introduces a test case to verify that errors returned from the MultiSelectWithSearch search function are properly propagated to the caller.
This commit is contained in:
parent
fb031b2b43
commit
af124cd5d2
1 changed files with 15 additions and 0 deletions
|
|
@ -420,6 +420,21 @@ func TestAccessiblePrompter(t *testing.T) {
|
|||
assert.Equal(t, expectedValues, multiSelectValues)
|
||||
})
|
||||
|
||||
t.Run("MultiSelectWithSearch - search error propagates", func(t *testing.T) {
|
||||
console := newTestVirtualTerminal(t)
|
||||
p := newTestAccessiblePrompter(t, console)
|
||||
|
||||
searchFunc := func(input string) prompter.MultiSelectSearchResult {
|
||||
return prompter.MultiSelectSearchResult{
|
||||
Err: fmt.Errorf("search error"),
|
||||
}
|
||||
}
|
||||
|
||||
_, err := p.MultiSelectWithSearch("Select", "Search", []string{}, []string{}, searchFunc)
|
||||
require.Error(t, err)
|
||||
require.Contains(t, err.Error(), "search error")
|
||||
})
|
||||
|
||||
t.Run("Input", func(t *testing.T) {
|
||||
console := newTestVirtualTerminal(t)
|
||||
p := newTestAccessiblePrompter(t, console)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue