-
Notifications
You must be signed in to change notification settings - Fork 0
/
config_test.go
36 lines (29 loc) · 986 Bytes
/
config_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
package xop
import (
"testing"
"time"
"github.com/stretchr/testify/assert"
)
func TestConfig(t *testing.T) {
seed := NewSeed()
assert.Equal(t, DefaultConfig.UseB3, seed.config.UseB3)
assert.Equal(t, DefaultConfig.FlushDelay, seed.config.FlushDelay)
seed = NewSeed(WithConfig(DefaultConfig), WithB3(true))
assert.Equal(t, true, seed.config.UseB3)
assert.Equal(t, DefaultConfig.FlushDelay, seed.config.FlushDelay)
seed = NewSeed(WithB3(true), WithFlushDelay(time.Second))
assert.Equal(t, true, seed.config.UseB3)
assert.Equal(t, time.Second, seed.config.FlushDelay)
}
func TestConfigModifier(t *testing.T) {
configModifier := func(cfg *Config) {
cfg.UseB3 = true
}
seed := NewSeed(WithConfigChanges(configModifier))
assert.Equal(t, true, seed.config.UseB3)
}
func TestLogConfig(t *testing.T) {
myLog := NewSeed().Request("myLog")
assert.Equal(t, DefaultConfig.FlushDelay, myLog.Config().FlushDelay)
assert.Equal(t, DefaultConfig.UseB3, myLog.Config().UseB3)
}