-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfield_test.go
33 lines (28 loc) · 920 Bytes
/
field_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package zl
import (
"github.com/stretchr/testify/assert"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
"testing"
)
func TestConsole(t *testing.T) {
field := Console("test")
expected := zap.Field{Key: consoleFieldDefault, Type: zapcore.StringType, String: "test"}
assert.Equal(t, expected, field)
}
func TestConsolep(t *testing.T) {
val := "pointerTest"
field := Consolep(&val)
expected := zap.Field{Key: consoleFieldDefault, Type: zapcore.StringType, String: "pointerTest"}
assert.Equal(t, expected, field)
nilField := Consolep(nil)
expectedNil := zap.Field{Key: consoleFieldDefault, Type: zapcore.StringType, String: ""}
assert.Equal(t, expectedNil, nilField)
}
func TestConsolef(t *testing.T) {
format := "Hello %s"
name := "World"
field := Consolef(format, name)
expected := zap.Field{Key: consoleFieldDefault, Type: zapcore.StringType, String: "Hello World"}
assert.Equal(t, expected, field)
}