-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from yaronius/master
Pass logger options
- Loading branch information
Showing
4 changed files
with
153 additions
and
86 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
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 |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package svc | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
"go.uber.org/zap" | ||
"go.uber.org/zap/zapcore" | ||
) | ||
|
||
func TestNewLogger(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
serviceOption Option | ||
}{ | ||
{ | ||
name: "console logger", | ||
serviceOption: WithConsoleLogger(zap.InfoLevel), | ||
}, | ||
{ | ||
name: "console logger with options", | ||
serviceOption: WithConsoleLogger(zap.DebugLevel, zap.WrapCore(func(core zapcore.Core) zapcore.Core { | ||
return core | ||
})), | ||
}, | ||
{ | ||
name: "development logger", | ||
serviceOption: WithDevelopmentLogger(), | ||
}, | ||
{ | ||
name: "development logger with options", | ||
serviceOption: WithDevelopmentLogger(zap.Development()), | ||
}, | ||
{ | ||
name: "production logger", | ||
serviceOption: WithProductionLogger(), | ||
}, | ||
{ | ||
name: "production logger with options", | ||
serviceOption: WithProductionLogger(zap.WithCaller(true)), | ||
}, | ||
{ | ||
name: "stackdriver logger", | ||
serviceOption: WithStackdriverLogger(zap.WarnLevel), | ||
}, | ||
{ | ||
name: "stackdriver logger with options", | ||
serviceOption: WithStackdriverLogger(zap.WarnLevel, zap.WrapCore(func(core zapcore.Core) zapcore.Core { | ||
return core | ||
}), zap.AddCaller()), | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
tc := tt | ||
t.Run(tc.name, func(t *testing.T) { | ||
_, err := New("dummy-name", "dummy-version", tc.serviceOption) | ||
require.NoError(t, err) | ||
}) | ||
} | ||
} |