ax(logging): rename TestLoggerLevels/TestLoggerDebugLevel to TestFilename_Function_{Good,Bad,Ugly}
AX test naming rule: TestFilename_Function_{Good,Bad,Ugly} — all three
categories mandatory. Splits the single test into the three required forms.
Co-Authored-By: Charon <charon@lethean.io>
This commit is contained in:
parent
2bfa958cfa
commit
8d323f7570
1 changed files with 18 additions and 9 deletions
|
|
@ -6,20 +6,14 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func TestLoggerLevels(t *testing.T) {
|
||||
func TestLogger_Log_Good(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
logger := New(Config{
|
||||
Output: &buf,
|
||||
Level: LevelInfo,
|
||||
})
|
||||
|
||||
// Debug should not appear at Info level
|
||||
logger.Debug("debug message")
|
||||
if buf.Len() > 0 {
|
||||
t.Error("Debug message should not appear at Info level")
|
||||
}
|
||||
|
||||
// Info should appear
|
||||
// Info should appear at Info level
|
||||
logger.Info("info message")
|
||||
if !strings.Contains(buf.String(), "[INFO]") {
|
||||
t.Error("Info message should appear")
|
||||
|
|
@ -43,13 +37,28 @@ func TestLoggerLevels(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestLoggerDebugLevel(t *testing.T) {
|
||||
func TestLogger_Log_Bad(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
logger := New(Config{
|
||||
Output: &buf,
|
||||
Level: LevelInfo,
|
||||
})
|
||||
|
||||
// Debug should not appear at Info level
|
||||
logger.Debug("debug message")
|
||||
if buf.Len() > 0 {
|
||||
t.Error("Debug message should not appear at Info level")
|
||||
}
|
||||
}
|
||||
|
||||
func TestLogger_Log_Ugly(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
logger := New(Config{
|
||||
Output: &buf,
|
||||
Level: LevelDebug,
|
||||
})
|
||||
|
||||
// All levels should appear at Debug level
|
||||
logger.Debug("debug message")
|
||||
if !strings.Contains(buf.String(), "[DEBUG]") {
|
||||
t.Error("Debug message should appear at Debug level")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue