7001ca854c
Queuing Changes and Cfg Testing * staarting * staarting * startedpush * note * save * mocking * removederrs * fixtests * cleanuperrs * newenvsetup * preppingtests * queue * mmovetocfgpassunittests * sortoutconfig * passinginteg * deps * fixtests
26 lines
600 B
Go
26 lines
600 B
Go
package logger
|
|
|
|
import (
|
|
"log/slog"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestTestLogger(t *testing.T) {
|
|
tl := &TestLogger{T: t}
|
|
logger := slog.New(tl)
|
|
slog.SetDefault(logger)
|
|
|
|
slog.Info("test message", "field", "value")
|
|
slog.Info("test message", "field", "second")
|
|
slog.Warn("test message", "field", "warn")
|
|
slog.Error("test message", "field", "error")
|
|
|
|
assert.Len(t, tl.Logs, 4)
|
|
assert.Equal(t, "value", tl.Logs[0]["field"])
|
|
assert.Equal(t, "second", tl.Logs[1]["field"])
|
|
assert.Equal(t, "warn", tl.Logs[2]["field"])
|
|
assert.Equal(t, "error", tl.Logs[3]["field"])
|
|
}
|