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

Function runForm

internal/prompter/huh_prompter_test.go:156–172  ·  view source on GitHub ↗

runForm runs a huh form with the given interaction, returning any error. The form runs in a goroutine using bubbletea's real event loop via io.Pipe.

(t *testing.T, f *huh.Form, ix interaction)

Source from the content-addressed store, hash-verified

154// runForm runs a huh form with the given interaction, returning any error.
155// The form runs in a goroutine using bubbletea's real event loop via io.Pipe.
156func runForm(t *testing.T, f *huh.Form, ix interaction) {
157 t.Helper()
158 r, w := io.Pipe()
159 f.WithInput(r).WithOutput(io.Discard).WithWidth(80)
160
161 errCh := make(chan error, 1)
162 go func() { errCh <- f.Run() }()
163
164 ix.run(t, w)
165
166 select {
167 case err := <-errCh:
168 require.NoError(t, err)
169 case <-time.After(5 * time.Second):
170 t.Fatal("form.Run() did not complete in time")
171 }
172}
173
174// --- Tests ---
175

Calls 4

WithWidthMethod · 0.80
runMethod · 0.80
HelperMethod · 0.65
RunMethod · 0.65

Tested by

no test coverage detected