MCPcopy Create free account
hub / github.com/conforma/cli / TestLoggerWritesToFile

Function TestLoggerWritesToFile

acceptance/log/log_test.go:32–56  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30)
31
32func TestLoggerWritesToFile(t *testing.T) {
33 ctx := context.Background()
34
35 loggerA, _ := LoggerFor(ctx)
36 loggerA.Name("ScenarioA")
37 defer loggerA.Close()
38 defer os.Remove(loggerA.LogFile())
39
40 loggerA.Log("hello from A")
41 loggerA.Logf("formatted %s", "message")
42 loggerA.Info("info msg")
43 loggerA.Warn("warn msg")
44 loggerA.Error("error msg")
45 loggerA.Close()
46
47 content, err := os.ReadFile(loggerA.LogFile())
48 require.NoError(t, err)
49
50 lines := string(content)
51 assert.Contains(t, lines, "hello from A")
52 assert.Contains(t, lines, "formatted message")
53 assert.Contains(t, lines, "[INFO ]")
54 assert.Contains(t, lines, "[WARN ]")
55 assert.Contains(t, lines, "[ERROR]")
56}
57
58func TestLoggerCaching(t *testing.T) {
59 ctx := context.Background()

Callers

nothing calls this directly

Calls 9

LoggerForFunction · 0.85
NameMethod · 0.65
CloseMethod · 0.65
LogFileMethod · 0.65
LogMethod · 0.65
LogfMethod · 0.65
InfoMethod · 0.65
WarnMethod · 0.65
ErrorMethod · 0.65

Tested by

no test coverage detected