Files
OpenFlare/backend/plugins/infra/logger/plugin_test.go
T
ryan 528240026d chore(lint): unify formatting on golangci-lint fmt (gofumpt), uncap issue reporting, fix gofumpt drift
- make format 现在与 code-check 使用同一格式化器(golangci-lint fmt),消除 goimports -local 与 gofumpt 的格式拉锯
- .golangci.yml 关闭默认 50/3 截断,完整上报所有问题(只增强不弱化)
- 全库 gofumpt 规范化(203 files, 纯格式无行为变更)
2026-08-28 16:31:53 +08:00

44 lines
1.0 KiB
Go

// Copyright 2026 Arctel.net
// SPDX-License-Identifier: Apache-2.0
package logger_test
import (
"Wavelet/core"
"Wavelet/core/contracts"
"Wavelet/plugins/infra/logger"
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestLoggerPluginOperations(t *testing.T) {
p := logger.New()
assert.Equal(t, "logger", p.Name())
ctx := core.NewContext(context.Background())
require.NoError(t, p.Apply(ctx))
svc, err := core.Inject[contracts.LoggerService](ctx)
require.NoError(t, err)
require.NotNil(t, svc)
testCtx := context.Background()
svc.Debug(testCtx, "debug msg", "key", "val")
svc.Info(testCtx, "info msg", "user", 1)
svc.Warn(testCtx, "warn msg", "odd_field")
svc.Error(testCtx, "error msg")
svc.Debugf(testCtx, "debug %s", "formatted")
svc.Infof(testCtx, "info %d", 100)
svc.Warnf(testCtx, "warn %v", true)
svc.Errorf(testCtx, "error %s", "fail")
withLogger := svc.With("trace", "t-123", "span", "s-456")
require.NotNil(t, withLogger)
withLogger.Info(testCtx, "enriched message")
}