Add more unit tests

This commit is contained in:
Jamie Curnow
2023-07-28 16:10:44 +10:00
parent e5ade3b4ea
commit b076f5b3b6
3 changed files with 286 additions and 0 deletions

View File

@ -45,11 +45,13 @@ func TestDebug(t *testing.T) {
assert.NoError(t, Configure(&Config{
LogThreshold: DebugLevel,
Formatter: "json",
}))
Debug("This is a %s message", "test")
assert.Contains(t, buf.String(), "DEBUG")
assert.Contains(t, buf.String(), "This is a test message")
Get()
}
func TestInfo(t *testing.T) {
@ -118,6 +120,16 @@ func TestConfigure(t *testing.T) {
},
wantErr: false,
},
{
name: "configure json",
args: args{
&Config{
LogThreshold: InfoLevel,
Formatter: "json",
},
},
wantErr: false,
},
{
name: "invalid log level",
args: args{
@ -125,6 +137,13 @@ func TestConfigure(t *testing.T) {
},
wantErr: true,
},
{
name: "invalid config struct",
args: args{
nil,
},
wantErr: true,
},
}
for _, tt := range tests {
tt := tt