-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils_test.go
More file actions
43 lines (36 loc) · 760 Bytes
/
utils_test.go
File metadata and controls
43 lines (36 loc) · 760 Bytes
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
package fusion
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
func TestLogFrom(t *testing.T) {
t.Parallel()
t.Run("NoContext", func(t *testing.T) {
log := LogFrom(context.Background())
assert.NotNil(t, log)
assert.NotPanics(t, func() {
log(nil)
})
})
t.Run("WithNilValue", func(t *testing.T) {
ctx := withLog(context.Background(), nil)
log := LogFrom(ctx)
assert.NotNil(t, log)
assert.NotPanics(t, func() {
log(nil)
})
})
t.Run("WithValue", func(t *testing.T) {
logged := false
ctx := withLog(context.Background(), func(_ map[string]interface{}) {
logged = true
})
log := LogFrom(ctx)
assert.NotNil(t, log)
assert.NotPanics(t, func() {
log(nil)
})
assert.True(t, logged)
})
}