Files
Memoh/internal/logger/logger_test.go
T
BBQ ca5c6a1866 refactor(core): restructure conversation, channel and message domains
- Rename chat module to conversation with flow-based architecture
- Move channelidentities into channel/identities subpackage
- Add channel/route for routing logic
- Add message service with event hub
- Add MCP providers: container, directory, schedule
- Refactor Feishu/Telegram adapters with directory and stream support
- Add platform management page and channel badges in web UI
- Update database schema for conversations, messages and channel routes
- Add @memoh/shared package for cross-package type definitions
2026-02-12 15:34:40 +08:00

52 lines
1.0 KiB
Go

package logger
import (
"context"
"log/slog"
"testing"
)
func TestInitAndLogging(t *testing.T) {
Init("debug", "json")
if L.Enabled(context.Background(), slog.LevelDebug) != true {
t.Error("expected debug level to be enabled")
}
Info("test info message", "key", "value")
}
func TestContextLogger(t *testing.T) {
Init("info", "text")
expectedKey := "request_id"
expectedValue := "12345"
customLogger := L.With(expectedKey, expectedValue)
ctx := WithContext(context.Background(), customLogger)
extracted := FromContext(ctx)
if extracted == nil {
t.Fatal("extracted logger should not be nil")
}
}
func TestParseLevel(t *testing.T) {
tests := []struct {
input string
expected slog.Level
}{
{"debug", slog.LevelDebug},
{"INFO", slog.LevelInfo},
{"Warn", slog.LevelWarn},
{"error", slog.LevelError},
{"unknown", slog.LevelInfo},
}
for _, tt := range tests {
if got := parseLevel(tt.input); got != tt.expected {
t.Errorf("parseLevel(%s) = %v, want %v", tt.input, got, tt.expected)
}
}
}