Files
query-orchestration/internal/serviceconfig/logger/testlogger_test.go
T
Michael McGuinness d91ef1832b Merged in feature/functestcov (pull request #84)
Function Test Coverage

* test

* scripts
2025-03-04 15:51:03 +00:00

29 lines
717 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"])
assert.NotNil(t, logger.Handler().WithAttrs([]slog.Attr{}))
assert.NotNil(t, logger.Handler().WithGroup("group"))
}