You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
637 B

2 years ago
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)
}
}