MCPcopy Index your code
hub / github.com/cli/cli / TestHuhPrompterInput

Function TestHuhPrompterInput

internal/prompter/huh_prompter_test.go:176–204  ·  view source on GitHub ↗

--- Tests ---

(t *testing.T)

Source from the content-addressed store, hash-verified

174// --- Tests ---
175
176func TestHuhPrompterInput(t *testing.T) {
177 tests := []struct {
178 name string
179 defaultValue string
180 ix interaction
181 wantResult string
182 }{
183 {
184 name: "basic input",
185 ix: newInteraction(typeKeys("hello"), enter()),
186 wantResult: "hello",
187 },
188 {
189 name: "default value returned when no input",
190 defaultValue: "default",
191 ix: newInteraction(enter()),
192 wantResult: "default",
193 },
194 }
195
196 for _, tt := range tests {
197 t.Run(tt.name, func(t *testing.T) {
198 p := newTestHuhPrompter()
199 f, result := p.buildInputForm("Name:", tt.defaultValue)
200 runForm(t, f, tt.ix)
201 require.Equal(t, tt.wantResult, *result)
202 })
203 }
204}
205
206func TestHuhPrompterSelect(t *testing.T) {
207 tests := []struct {

Callers

nothing calls this directly

Calls 8

newInteractionFunction · 0.85
typeKeysFunction · 0.85
enterFunction · 0.85
newTestHuhPrompterFunction · 0.85
runFormFunction · 0.85
buildInputFormMethod · 0.80
EqualMethod · 0.80
RunMethod · 0.65

Tested by

no test coverage detected