(t *testing.T)
| 135 | } |
| 136 | |
| 137 | func TestSignalUnixForceRefreshCleansTerminal(t *testing.T) { |
| 138 | logger, _ := zap.NewDevelopment() |
| 139 | defer func(logger *zap.Logger) { |
| 140 | err := logger.Sync() |
| 141 | if err != nil { |
| 142 | return |
| 143 | } |
| 144 | }(logger) |
| 145 | |
| 146 | oldStdout := os.Stdout |
| 147 | r, w, _ := os.Pipe() |
| 148 | os.Stdout = w |
| 149 | |
| 150 | cli := &ChatCLI{logger: logger} |
| 151 | cli.forceRefreshPrompt() |
| 152 | |
| 153 | w.Close() |
| 154 | os.Stdout = oldStdout |
| 155 | out, _ := io.ReadAll(r) |
| 156 | output := string(out) |
| 157 | |
| 158 | if !strings.Contains(output, "\033[K") { |
| 159 | t.Error("Expected output to contain clear line sequence") |
| 160 | } |
| 161 | if !strings.Contains(output, "\033[0m") { |
| 162 | t.Error("Expected output to contain ANSI reset") |
| 163 | } |
| 164 | } |
nothing calls this directly
no test coverage detected