Skip to content

Commit

Permalink
test: add SetLevel test
Browse files Browse the repository at this point in the history
  • Loading branch information
zbindenren committed Dec 23, 2020
1 parent acf886d commit dab1cf5
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions flash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/stretchr/testify/require"
"github.com/tj/assert"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)

// nolint: gochecknoglobals
Expand Down Expand Up @@ -99,6 +100,12 @@ func TestSetDebugWithStacktrace(t *testing.T) {
assert.NotEmpty(t, sink.String(), "no debug message logged")
l.Error("error")
assert.True(t, sink.containsStackTrace(), "stack trace detected")
sink.Reset()
l.SetDebug(false)
l.Debug("debug")
assert.Empty(t, sink.String())
l.Error("error")
assert.False(t, sink.containsStackTrace())
}

func TestDisable(t *testing.T) {
Expand All @@ -115,6 +122,17 @@ func TestDisable(t *testing.T) {
assert.Empty(t, sink.String(), 0)
}

func TestSetLeve(t *testing.T) {
defer sink.Reset()

l := flash.New(flash.WithSink("memory://"))
l.Debug("debug")
assert.Empty(t, sink.String(), 0)
l.SetLevel(zapcore.DebugLevel)
l.Debug("debug")
assert.NotEmpty(t, sink.String(), 0)
}

func TestWithPrometheus(t *testing.T) {
defer sink.Reset()

Expand Down

0 comments on commit dab1cf5

Please sign in to comment.