restore v 0.2.0
This commit is contained in:
31
logger_test.go
Normal file
31
logger_test.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package log_test
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"gitoa.ru/go-4devs/log"
|
||||
)
|
||||
|
||||
func TestFields(t *testing.T) {
|
||||
type rObj struct {
|
||||
id string
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
buf := &bytes.Buffer{}
|
||||
log := log.New(log.WithWriter(buf))
|
||||
success := "msg=\"message\" err=file already exists version=0.1.0 obj={id:uid}\n"
|
||||
|
||||
log.InfoKV(ctx, "message",
|
||||
"err", os.ErrExist,
|
||||
"version", "0.1.0",
|
||||
"obj", rObj{id: "uid"},
|
||||
)
|
||||
|
||||
if success != buf.String() {
|
||||
t.Errorf("invalid value\n got:%s\n exp:%s", buf, success)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user