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)
| 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. |
| 156 | func 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 |
no test coverage detected