Skip to content

Commit

Permalink
Increase coverage for xoplog/config.go file to 90%.
Browse files Browse the repository at this point in the history
  • Loading branch information
miccagiann committed Aug 24, 2022
1 parent 1cedc2b commit 9bd2c58
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,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)
}

0 comments on commit 9bd2c58

Please sign in to comment.