forked from kevadesu/forgejo
[TESTS] add log.Level to test.NewLogChecker
So the caller can check log events at the desired level instead of
being limited to the default level log.INFO
(cherry picked from commit 2fbf5f9555
)
This commit is contained in:
parent
4e8f6b2ffd
commit
e2137a3147
4 changed files with 22 additions and 7 deletions
|
@ -12,8 +12,8 @@ import (
|
|||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestLogChecker(t *testing.T) {
|
||||
lc, cleanup := NewLogChecker(log.DEFAULT)
|
||||
func TestLogCheckerInfo(t *testing.T) {
|
||||
lc, cleanup := NewLogChecker(log.DEFAULT, log.INFO)
|
||||
defer cleanup()
|
||||
|
||||
lc.Filter("First", "Third").StopMark("End")
|
||||
|
@ -24,11 +24,13 @@ func TestLogChecker(t *testing.T) {
|
|||
assert.False(t, stopped)
|
||||
|
||||
log.Info("First")
|
||||
log.Debug("Third")
|
||||
filtered, stopped = lc.Check(100 * time.Millisecond)
|
||||
assert.ElementsMatch(t, []bool{true, false}, filtered)
|
||||
assert.False(t, stopped)
|
||||
|
||||
log.Info("Second")
|
||||
log.Debug("Third")
|
||||
filtered, stopped = lc.Check(100 * time.Millisecond)
|
||||
assert.ElementsMatch(t, []bool{true, false}, filtered)
|
||||
assert.False(t, stopped)
|
||||
|
@ -43,3 +45,14 @@ func TestLogChecker(t *testing.T) {
|
|||
assert.ElementsMatch(t, []bool{true, true}, filtered)
|
||||
assert.True(t, stopped)
|
||||
}
|
||||
|
||||
func TestLogCheckerDebug(t *testing.T) {
|
||||
lc, cleanup := NewLogChecker(log.DEFAULT, log.DEBUG)
|
||||
defer cleanup()
|
||||
|
||||
lc.StopMark("End")
|
||||
|
||||
log.Debug("End")
|
||||
_, stopped := lc.Check(100 * time.Millisecond)
|
||||
assert.True(t, stopped)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue