MCPcopy
hub / github.com/cli/cli / TestHuhPrompterInput

Function TestHuhPrompterInput

internal/prompter/huh_prompter_test.go:134–162  ·  view source on GitHub ↗

--- Tests ---

(t *testing.T)

Source from the content-addressed store, hash-verified

132// --- Tests ---
133
134func TestHuhPrompterInput(t *testing.T) {
135 tests := []struct {
136 name string
137 defaultValue string
138 ix interaction
139 wantResult string
140 }{
141 {
142 name: "basic input",
143 ix: newInteraction(typeKeys("hello"), enter()),
144 wantResult: "hello",
145 },
146 {
147 name: "default value returned when no input",
148 defaultValue: "default",
149 ix: newInteraction(enter()),
150 wantResult: "default",
151 },
152 }
153
154 for _, tt := range tests {
155 t.Run(tt.name, func(t *testing.T) {
156 p := newTestHuhPrompter()
157 f, result := p.buildInputForm("Name:", tt.defaultValue)
158 runForm(t, f, tt.ix)
159 require.Equal(t, tt.wantResult, *result)
160 })
161 }
162}
163
164func TestHuhPrompterSelect(t *testing.T) {
165 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