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

Function TestLoggerIsolation

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

Source from the content-addressed store, hash-verified

85}
86
87func TestLoggerIsolation(t *testing.T) {
88 ctxA := context.Background()
89 ctxB := context.Background()
90
91 loggerA, _ := LoggerFor(ctxA)
92 loggerA.Name("A")
93 defer loggerA.Close()
94 defer os.Remove(loggerA.LogFile())
95
96 loggerB, _ := LoggerFor(ctxB)
97 loggerB.Name("B")
98 defer loggerB.Close()
99 defer os.Remove(loggerB.LogFile())
100
101 loggerA.Log("only in A")
102 loggerB.Log("only in B")
103
104 loggerA.Close()
105 loggerB.Close()
106
107 contentA, err := os.ReadFile(loggerA.LogFile())
108 require.NoError(t, err)
109 contentB, err := os.ReadFile(loggerB.LogFile())
110 require.NoError(t, err)
111
112 assert.Contains(t, string(contentA), "only in A")
113 assert.NotContains(t, string(contentA), "only in B")
114 assert.Contains(t, string(contentB), "only in B")
115 assert.NotContains(t, string(contentB), "only in A")
116}
117
118func TestLogFileCreatesTemporaryFile(t *testing.T) {
119 ctx := context.Background()

Callers

nothing calls this directly

Calls 5

LoggerForFunction · 0.85
NameMethod · 0.65
CloseMethod · 0.65
LogFileMethod · 0.65
LogMethod · 0.65

Tested by

no test coverage detected