-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove init register pattern * codecov: rename config file
- Loading branch information
Showing
15 changed files
with
347 additions
and
344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,45 +1,51 @@ | ||
package clog | ||
|
||
import ( | ||
"errors" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func Test_ModeConsole(t *testing.T) { | ||
defer Remove(ModeConsole) | ||
func Test_consoleLogger(t *testing.T) { | ||
testName := "Test_consoleLogger" | ||
defer Remove(DefaultConsoleName) | ||
defer Remove(testName) | ||
|
||
tests := []struct { | ||
name string | ||
mode string | ||
config interface{} | ||
wantLevel Level | ||
wantErr error | ||
}{ | ||
{ | ||
name: "nil config", | ||
mode: DefaultConsoleName, | ||
wantErr: nil, | ||
}, | ||
{ | ||
name: "valid config", | ||
mode: DefaultConsoleName, | ||
config: ConsoleConfig{ | ||
Level: LevelInfo, | ||
}, | ||
wantErr: nil, | ||
}, | ||
{ | ||
name: "invalid config", | ||
config: "random things", | ||
wantErr: errors.New("initialize logger: invalid config object: want clog.ConsoleConfig got string"), | ||
name: "custom name", | ||
mode: testName, | ||
wantErr: nil, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
assert.Equal(t, tt.wantErr, New(ModeConsole, 10, tt.config)) | ||
assert.Equal(t, tt.wantErr, NewConsoleWithName(tt.mode, 10, tt.config)) | ||
}) | ||
} | ||
|
||
assert.Equal(t, 1, mgr.len()) | ||
assert.Equal(t, ModeConsole, mgr.loggers[0].Mode()) | ||
assert.Equal(t, 2, mgr.len()) | ||
assert.Equal(t, DefaultConsoleName, mgr.loggers[0].Name()) | ||
assert.Equal(t, LevelInfo, mgr.loggers[0].Level()) | ||
assert.Equal(t, testName, mgr.loggers[1].Name()) | ||
assert.Equal(t, LevelTrace, mgr.loggers[1].Level()) | ||
} |
Oops, something went wrong.