MCPcopy
hub / github.com/cli/cli / TestHelperProcess

Function TestHelperProcess

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

Source from the content-addressed store, hash-verified

21}
22
23func TestHelperProcess(t *testing.T) {
24 if os.Getenv("GH_WANT_HELPER_PROCESS") != "1" {
25 return
26 }
27 if err := func(args []string) error {
28 switch args[0] {
29 // "vim" appends a message to the file
30 case "vim":
31 f, err := os.OpenFile(args[1], os.O_APPEND|os.O_WRONLY, 0)
32 if err != nil {
33 return err
34 }
35 defer f.Close()
36 _, err = f.WriteString(" - added by vim")
37 return err
38 // "nano" truncates the contents of the file
39 case "nano":
40 f, err := os.OpenFile(args[1], os.O_TRUNC|os.O_WRONLY, 0)
41 if err != nil {
42 return err
43 }
44 return f.Close()
45 default:
46 return fmt.Errorf("unrecognized arguments: %#v\n", args)
47 }
48 }(os.Args[3:]); err != nil {
49 fmt.Fprintln(os.Stderr, err)
50 os.Exit(1)
51 }
52 os.Exit(0)
53}
54
55func Test_GhEditor_Prompt_skip(t *testing.T) {
56 pty := newTerminal(t)

Callers

nothing calls this directly

Calls 2

CloseMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected