(t *testing.T)
| 53 | } |
| 54 | |
| 55 | func Test_GhEditor_Prompt_skip(t *testing.T) { |
| 56 | pty := newTerminal(t) |
| 57 | |
| 58 | e := &GhEditor{ |
| 59 | BlankAllowed: true, |
| 60 | EditorCommand: "vim", |
| 61 | Editor: &survey.Editor{ |
| 62 | Message: "Body", |
| 63 | FileName: "*.md", |
| 64 | Default: "initial value", |
| 65 | HideDefault: true, |
| 66 | AppendDefault: true, |
| 67 | }, |
| 68 | lookPath: func(s string) ([]string, []string, error) { |
| 69 | return nil, nil, errors.New("no editor allowed") |
| 70 | }, |
| 71 | } |
| 72 | e.WithStdio(pty.Stdio()) |
| 73 | |
| 74 | // wait until the prompt is rendered and send the Enter key |
| 75 | go func() { |
| 76 | pty.WaitForOutput("Body") |
| 77 | assert.Equal(t, "\x1b[0G\x1b[2K\x1b[0;1;92m? \x1b[0m\x1b[0;1;99mBody \x1b[0m\x1b[0;36m[(e) to launch vim, enter to skip] \x1b[0m", normalizeANSI(pty.Output())) |
| 78 | pty.ResetOutput() |
| 79 | assert.NoError(t, pty.SendKey('\n')) |
| 80 | }() |
| 81 | |
| 82 | res, err := e.Prompt(defaultPromptConfig()) |
| 83 | assert.NoError(t, err) |
| 84 | assert.Equal(t, "initial value", res) |
| 85 | assert.Equal(t, "", normalizeANSI(pty.Output())) |
| 86 | } |
| 87 | |
| 88 | func Test_GhEditor_Prompt_editorAppend(t *testing.T) { |
| 89 | pty := newTerminal(t) |
nothing calls this directly
no test coverage detected