MCPcopy
hub / github.com/keploy/keploy / TestAddDebugFileSink_BeforeAttach_NotInFile

Function TestAddDebugFileSink_BeforeAttach_NotInFile

utils/log/logger_test.go:43–69  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

41func (b *syncBuffer) String() string { return b.mu.String() }
42
43func TestAddDebugFileSink_BeforeAttach_NotInFile(t *testing.T) {
44 SetRedactor(nil)
45 console := &syncBuffer{}
46 logger := newConsoleLogger(console, zap.InfoLevel)
47
48 logger.Info("before-attach")
49
50 tmp, err := os.CreateTemp(t.TempDir(), "before-*.log")
51 if err != nil {
52 t.Fatalf("create temp: %v", err)
53 }
54 defer tmp.Close()
55 wrapped, sink := AddDebugFileSink(logger, tmp, 0)
56 if wrapped == nil || sink == nil {
57 t.Fatalf("AddDebugFileSink returned nil")
58 }
59 if err := sink.Flush(); err != nil {
60 t.Fatalf("flush: %v", err)
61 }
62 contents, err := os.ReadFile(tmp.Name())
63 if err != nil {
64 t.Fatalf("read: %v", err)
65 }
66 if len(contents) != 0 {
67 t.Fatalf("expected empty file before any writes after attach, got %q", contents)
68 }
69}
70
71func TestAddDebugFileSink_AfterAttach_DebugLandsInFile(t *testing.T) {
72 SetRedactor(nil)

Callers

nothing calls this directly

Calls 6

SetRedactorFunction · 0.85
newConsoleLoggerFunction · 0.85
AddDebugFileSinkFunction · 0.85
FlushMethod · 0.80
NameMethod · 0.80
CloseMethod · 0.65

Tested by

no test coverage detected