-
Notifications
You must be signed in to change notification settings - Fork 1
/
builder_test.go
53 lines (40 loc) · 1.07 KB
/
builder_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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package go_logger
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestBuilder(t *testing.T) {
initializedFields := make(map[string]interface{})
builder := Builder()
assert.Equal(t, builder.fields, initializedFields)
assert.Equal(t, builder.contextFields, initializedFields)
}
func TestBuilder_AddField(t *testing.T) {
expectedFields := map[string]interface{}{
"test": "value",
}
builder := Builder()
builder.AddField("test", "value")
assert.Equal(t, expectedFields, builder.fields)
}
func TestBuilder_AddContextField(t *testing.T) {
expectedContextFields := map[string]interface{}{
"test": "value",
}
builder := Builder()
builder.AddContextField("test", "value")
assert.Equal(t, expectedContextFields, builder.contextFields)
}
func TestBuilder_GetFields(t *testing.T) {
expectedFields := map[string]interface{}{
"test": "value",
"context": map[string]interface{}{
"foo": "bar",
},
}
builder := Builder()
builder.
AddField("test", "value").
AddContextField("foo", "bar")
assert.Equal(t, expectedFields, builder.getFields())
}