mirror of
https://github.com/go-kratos/kratos.git
synced 2025-01-24 03:46:37 +02:00
7cd9503b95
* test: add log test * fix * fix lint
31 lines
637 B
Go
31 lines
637 B
Go
package log
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
)
|
|
|
|
func TestValue(t *testing.T) {
|
|
logger := DefaultLogger
|
|
logger = With(logger, "ts", DefaultTimestamp, "caller", DefaultCaller)
|
|
_ = logger.Log(LevelInfo, "msg", "helloworld")
|
|
|
|
logger = DefaultLogger
|
|
logger = With(logger)
|
|
_ = logger.Log(LevelDebug, "msg", "helloworld")
|
|
|
|
var v1 interface{}
|
|
got := Value(context.Background(), v1)
|
|
if got != v1 {
|
|
t.Errorf("Value() = %v, want %v", got, v1)
|
|
}
|
|
var v2 Valuer = func(ctx context.Context) interface{} {
|
|
return 3
|
|
}
|
|
got = Value(context.Background(), v2)
|
|
res := got.(int)
|
|
if res != 3 {
|
|
t.Errorf("Value() = %v, want %v", res, 3)
|
|
}
|
|
}
|