(t *testing.T)
| 666 | } |
| 667 | |
| 668 | func TestRunFormTranslatesErrUserAborted(t *testing.T) { |
| 669 | p := newTestHuhPrompter() |
| 670 | form, _ := p.buildSelectForm("Pick one:", "", []string{"a", "b", "c"}) |
| 671 | |
| 672 | r, w := io.Pipe() |
| 673 | form.WithInput(r).WithOutput(io.Discard).WithWidth(80) |
| 674 | |
| 675 | errCh := make(chan error, 1) |
| 676 | go func() { errCh <- p.runForm(form) }() |
| 677 | |
| 678 | // Send Ctrl+C to trigger huh.ErrUserAborted |
| 679 | _, err := w.Write([]byte{0x03}) |
| 680 | require.NoError(t, err) |
| 681 | |
| 682 | select { |
| 683 | case err := <-errCh: |
| 684 | assert.ErrorIs(t, err, terminal.InterruptErr, "expected huh.ErrUserAborted to be translated to terminal.InterruptErr") |
| 685 | case <-time.After(5 * time.Second): |
| 686 | t.Fatal("runForm did not complete in time") |
| 687 | } |
| 688 | } |
nothing calls this directly
no test coverage detected