(t *testing.T)
| 621 | } |
| 622 | |
| 623 | func TestRunFormTranslatesErrUserAborted(t *testing.T) { |
| 624 | p := newTestHuhPrompter() |
| 625 | form, _ := p.buildSelectForm("Pick one:", "", []string{"a", "b", "c"}) |
| 626 | |
| 627 | r, w := io.Pipe() |
| 628 | form.WithInput(r).WithOutput(io.Discard).WithWidth(80) |
| 629 | |
| 630 | errCh := make(chan error, 1) |
| 631 | go func() { errCh <- p.runForm(form) }() |
| 632 | |
| 633 | // Send Ctrl+C to trigger huh.ErrUserAborted |
| 634 | _, err := w.Write([]byte{0x03}) |
| 635 | require.NoError(t, err) |
| 636 | |
| 637 | select { |
| 638 | case err := <-errCh: |
| 639 | assert.ErrorIs(t, err, terminal.InterruptErr, "expected huh.ErrUserAborted to be translated to terminal.InterruptErr") |
| 640 | case <-time.After(5 * time.Second): |
| 641 | t.Fatal("runForm did not complete in time") |
| 642 | } |
| 643 | } |
nothing calls this directly
no test coverage detected