Files
OpenFlare/backend/plugins/infra/logger/plugin_test.go
T
ryan f2ab94501c refactor(layout): relocate go.mod to backend/ and clean import paths to module root
- Relocated go.mod and go.sum into backend/ root directory
- Stripped redundant backend/ segments from all Go imports (github.com/Rain-kl/Wavelet/...)
- Unified Makefile, swagger, and build-test to execute in backend/ module context
- Ensured 100% build-test, code-check, format, and swagger pass
2026-08-28 13:01:51 +08:00

45 lines
1.1 KiB
Go

// Copyright 2026 Arctel.net
// SPDX-License-Identifier: Apache-2.0
package logger_test
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/Rain-kl/Wavelet/core"
"github.com/Rain-kl/Wavelet/core/contracts"
"github.com/Rain-kl/Wavelet/plugins/infra/logger"
)
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")
}