MCPcopy Index your code
hub / github.com/cheat/cheat / TestWriteToPagerError

Function TestWriteToPagerError

internal/display/write_test.go:113–136  ·  view source on GitHub ↗

TestWriteToPagerError tests error handling in writeToPager

(t *testing.T)

Source from the content-addressed store, hash-verified

111
112// TestWriteToPagerError tests error handling in writeToPager
113func TestWriteToPagerError(t *testing.T) {
114 if os.Getenv("TEST_PAGER_ERROR_SUBPROCESS") == "1" {
115 // This is the subprocess - run the actual test
116 conf := config.Config{Pager: "/nonexistent/command"}
117 writeToPager("test", conf)
118 return
119 }
120
121 // Run test in subprocess to handle os.Exit
122 cmd := exec.Command(os.Args[0], "-test.run=^TestWriteToPagerError$")
123 cmd.Env = append(os.Environ(), "TEST_PAGER_ERROR_SUBPROCESS=1")
124
125 output, err := cmd.CombinedOutput()
126
127 // Should exit with error
128 if err == nil {
129 t.Error("expected process to exit with error")
130 }
131
132 // Should contain error message
133 if !strings.Contains(string(output), "failed to write to pager") {
134 t.Errorf("expected error message about pager failure, got %q", string(output))
135 }
136}

Callers

nothing calls this directly

Calls 1

writeToPagerFunction · 0.85

Tested by

no test coverage detected