MCPcopy Create free account
hub / github.com/diillson/chatcli / TestTeeLoggerToGatewayLog

Function TestTeeLoggerToGatewayLog

cli/gateway_command_test.go:238–256  ·  view source on GitHub ↗

TestTeeLoggerToGatewayLog verifies the daemon's logger is teed into the advertised gateway.log so the file is not a false promise.

(t *testing.T)

Source from the content-addressed store, hash-verified

236// TestTeeLoggerToGatewayLog verifies the daemon's logger is teed into the
237// advertised gateway.log so the file is not a false promise.
238func 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}

Callers

nothing calls this directly

Calls 3

teeLoggerToGatewayLogMethod · 0.95
ErrorfMethod · 0.80
InfoMethod · 0.65

Tested by

no test coverage detected