Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

testing: fix usage of the Testify API #1427

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 6 additions & 6 deletions entry_test.go
Expand Up @@ -241,20 +241,20 @@ func TestEntryWithIncorrectField(t *testing.T) {
eWithFunc := e.WithFields(Fields{"func": fn})
eWithFuncPtr := e.WithFields(Fields{"funcPtr": &fn})

assert.Equal(eWithFunc.err, `can not add field "func"`)
assert.Equal(eWithFuncPtr.err, `can not add field "funcPtr"`)
assert.Equal(`can not add field "func"`, eWithFunc.err)
assert.Equal(`can not add field "funcPtr"`, eWithFuncPtr.err)

eWithFunc = eWithFunc.WithField("not_a_func", "it is a string")
eWithFuncPtr = eWithFuncPtr.WithField("not_a_func", "it is a string")

assert.Equal(eWithFunc.err, `can not add field "func"`)
assert.Equal(eWithFuncPtr.err, `can not add field "funcPtr"`)
assert.Equal(`can not add field "func"`, eWithFunc.err)
assert.Equal(`can not add field "funcPtr"`, eWithFuncPtr.err)

eWithFunc = eWithFunc.WithTime(time.Now())
eWithFuncPtr = eWithFuncPtr.WithTime(time.Now())

assert.Equal(eWithFunc.err, `can not add field "func"`)
assert.Equal(eWithFuncPtr.err, `can not add field "funcPtr"`)
assert.Equal(`can not add field "func"`, eWithFunc.err)
assert.Equal(`can not add field "funcPtr"`, eWithFuncPtr.err)
}

func TestEntryLogfLevel(t *testing.T) {
Expand Down
14 changes: 7 additions & 7 deletions hook_test.go
Expand Up @@ -41,11 +41,11 @@ func TestHookFires(t *testing.T) {

LogAndAssertJSON(t, func(log *Logger) {
log.Hooks.Add(hook)
assert.Equal(t, hook.Fired, false)
assert.False(t, hook.Fired)

log.Print("test")
}, func(fields Fields) {
assert.Equal(t, hook.Fired, true)
assert.True(t, hook.Fired)
})
}

Expand Down Expand Up @@ -76,7 +76,7 @@ func TestHookCanModifyEntry(t *testing.T) {
log.Hooks.Add(hook)
log.WithField("wow", "elephant").Print("test")
}, func(fields Fields) {
assert.Equal(t, fields["wow"], "whale")
assert.Equal(t, "whale", fields["wow"])
})
}

Expand All @@ -90,8 +90,8 @@ func TestCanFireMultipleHooks(t *testing.T) {

log.WithField("wow", "elephant").Print("test")
}, func(fields Fields) {
assert.Equal(t, fields["wow"], "whale")
assert.Equal(t, hook2.Fired, true)
assert.Equal(t, "whale", fields["wow"])
assert.True(t, hook2.Fired)
})
}

Expand Down Expand Up @@ -157,7 +157,7 @@ func TestErrorHookShouldntFireOnInfo(t *testing.T) {
log.Hooks.Add(hook)
log.Info("test")
}, func(fields Fields) {
assert.Equal(t, hook.Fired, false)
assert.False(t, hook.Fired)
})
}

Expand All @@ -168,7 +168,7 @@ func TestErrorHookShouldFireOnError(t *testing.T) {
log.Hooks.Add(hook)
log.Error("test")
}, func(fields Fields) {
assert.Equal(t, hook.Fired, true)
assert.True(t, hook.Fired)
})
}

Expand Down
4 changes: 2 additions & 2 deletions hooks/writer/writer_test.go
Expand Up @@ -33,6 +33,6 @@ func TestDifferentLevelsGoToDifferentWriters(t *testing.T) {
log.Warn("send to a")
log.Info("send to b")

assert.Equal(t, a.String(), "level=warning msg=\"send to a\"\n")
assert.Equal(t, b.String(), "level=info msg=\"send to b\"\n")
assert.Equal(t, "level=warning msg=\"send to a\"\n", a.String())
assert.Equal(t, "level=info msg=\"send to b\"\n", b.String())
}
4 changes: 2 additions & 2 deletions logger_test.go
Expand Up @@ -70,7 +70,7 @@ func TestWarninglnNotEqualToWarning(t *testing.T) {

type testBufferPool struct {
buffers []*bytes.Buffer
get int
get int
}

func (p *testBufferPool) Get() *bytes.Buffer {
Expand All @@ -92,6 +92,6 @@ func TestLogger_SetBufferPool(t *testing.T) {

l.Info("test")

assert.Equal(t, pool.get, 1, "Logger.SetBufferPool(): The BufferPool.Get() must be called")
assert.Equal(t, 1, pool.get, "Logger.SetBufferPool(): The BufferPool.Get() must be called")
assert.Len(t, pool.buffers, 1, "Logger.SetBufferPool(): The BufferPool.Put() must be called")
}