MCPcopy
hub / github.com/cli/cli / TestIOStreams_pager

Function TestIOStreams_pager

pkg/iostreams/iostreams_test.go:27–47  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

25}
26
27func TestIOStreams_pager(t *testing.T) {
28 t.Skip("TODO: fix this test in race detection mode")
29 ios, _, stdout, _ := Test()
30 ios.SetStdoutTTY(true)
31 ios.SetPager(fmt.Sprintf("%s -test.run=TestHelperProcess --", os.Args[0]))
32 t.Setenv("GH_WANT_HELPER_PROCESS", "1")
33 if err := ios.StartPager(); err != nil {
34 t.Fatal(err)
35 }
36 if _, err := fmt.Fprintln(ios.Out, "line1"); err != nil {
37 t.Errorf("error writing line 1: %v", err)
38 }
39 if _, err := fmt.Fprintln(ios.Out, "line2"); err != nil {
40 t.Errorf("error writing line 2: %v", err)
41 }
42 ios.StopPager()
43 wants := "pager: line1\npager: line2\n"
44 if got := stdout.String(); got != wants {
45 t.Errorf("expected %q, got %q", wants, got)
46 }
47}
48
49func TestHelperProcess(t *testing.T) {
50 if os.Getenv("GH_WANT_HELPER_PROCESS") != "1" {

Callers

nothing calls this directly

Calls 8

TestFunction · 0.85
SkipMethod · 0.80
SetStdoutTTYMethod · 0.80
SetPagerMethod · 0.80
StartPagerMethod · 0.80
StopPagerMethod · 0.80
ErrorfMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected