TestWriteToPagerError tests error handling in writeToPager
(t *testing.T)
| 111 | |
| 112 | // TestWriteToPagerError tests error handling in writeToPager |
| 113 | func 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 | } |
nothing calls this directly
no test coverage detected