MCPcopy
hub / github.com/cli/cli / runForm

Function runForm

internal/prompter/huh_prompter_test.go:114–130  ·  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

112// runForm runs a huh form with the given interaction, returning any error.
113// The form runs in a goroutine using bubbletea's real event loop via io.Pipe.
114func runForm(t *testing.T, f *huh.Form, ix interaction) {
115 t.Helper()
116 r, w := io.Pipe()
117 f.WithInput(r).WithOutput(io.Discard).WithWidth(80)
118
119 errCh := make(chan error, 1)
120 go func() { errCh <- f.Run() }()
121
122 ix.run(t, w)
123
124 select {
125 case err := <-errCh:
126 require.NoError(t, err)
127 case <-time.After(5 * time.Second):
128 t.Fatal("form.Run() did not complete in time")
129 }
130}
131
132// --- Tests ---
133

Calls 4

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

Tested by

no test coverage detected