Files
logging/log_test.go
argoyle a705fc33c4
logging / test (push) Has been skipped
logging / vulnerabilities (push) Has been skipped
Release / release (push) Successful in 56s
logging / coverage-baseline (push) Successful in 2m49s
pre-commit / pre-commit (push) Successful in 5m29s
feat: move MockLogger into a logtest sub-package (#5)
2026-06-19 16:43:26 +00:00

26 lines
624 B
Go

package logging
import (
"context"
"log/slog"
"testing"
"github.com/stretchr/testify/assert"
)
func TestSetupLogger(t *testing.T) {
for _, format := range []string{"text", "json"} {
l := SetupLogger("info", format, "test-service", "v0.0.0")
assert.NotNil(t, l)
assert.Same(t, l, slog.Default())
}
}
func TestContextLogger(t *testing.T) {
base := SetupLogger("info", "text", "svc", "v1")
assert.Same(t, base, LoggerFromContext(context.Background()))
custom := slog.New(slog.NewTextHandler(nil, nil))
ctx := ContextWithLogger(context.Background(), custom)
assert.Same(t, custom, LoggerFromContext(ctx))
}