TestTeeLoggerToGatewayLog verifies the daemon's logger is teed into the advertised gateway.log so the file is not a false promise.
(t *testing.T)
| 236 | // TestTeeLoggerToGatewayLog verifies the daemon's logger is teed into the |
| 237 | // advertised gateway.log so the file is not a false promise. |
| 238 | func TestTeeLoggerToGatewayLog(t *testing.T) { |
| 239 | tmp := t.TempDir() |
| 240 | t.Setenv("HOME", tmp) |
| 241 | c := &ChatCLI{logger: zap.NewNop()} |
| 242 | closeTee := c.teeLoggerToGatewayLog() |
| 243 | if closeTee == nil { |
| 244 | t.Fatal("expected a non-nil closer when gateway.log is writable") |
| 245 | } |
| 246 | c.logger.Info("hello-gateway-log") |
| 247 | closeTee() |
| 248 | |
| 249 | data, err := os.ReadFile(filepath.Join(tmp, ".chatcli", "gateway.log")) |
| 250 | if err != nil { |
| 251 | t.Fatalf("gateway.log not written: %v", err) |
| 252 | } |
| 253 | if !strings.Contains(string(data), "hello-gateway-log") { |
| 254 | t.Errorf("gateway.log missing the teed entry: %s", data) |
| 255 | } |
| 256 | } |
nothing calls this directly
no test coverage detected