MCPcopy Index your code
hub / github.com/cli/cli / Test_GhEditor_Prompt_skip

Function Test_GhEditor_Prompt_skip

pkg/surveyext/editor_test.go:55–86  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

53}
54
55func 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
88func Test_GhEditor_Prompt_editorAppend(t *testing.T) {
89 pty := newTerminal(t)

Callers

nothing calls this directly

Calls 10

PromptMethod · 0.95
newTerminalFunction · 0.85
normalizeANSIFunction · 0.85
defaultPromptConfigFunction · 0.85
StdioMethod · 0.80
WaitForOutputMethod · 0.80
EqualMethod · 0.80
ResetOutputMethod · 0.80
SendKeyMethod · 0.80
OutputMethod · 0.65

Tested by

no test coverage detected