Add testing
This commit is contained in:
parent
3233f8c27f
commit
06e6d457da
14 changed files with 273 additions and 5 deletions
|
@ -12,10 +12,16 @@ type ZerologGormAdapter struct {
|
|||
logger zerolog.Logger
|
||||
}
|
||||
|
||||
// Compile time interface implementation enforcement
|
||||
var _ logger.Interface = &ZerologGormAdapter{}
|
||||
|
||||
// Not worth testing as just a wrapper for putting into a struct
|
||||
func NewGormLogger(zerologger zerolog.Logger) *ZerologGormAdapter {
|
||||
return &ZerologGormAdapter{zerologger}
|
||||
}
|
||||
|
||||
// Not testable since it focuses entirely on the side effect of
|
||||
// configuring loglevel
|
||||
func (g *ZerologGormAdapter) LogMode(newLevel logger.LogLevel) logger.Interface {
|
||||
switch newLevel {
|
||||
case logger.Error:
|
||||
|
@ -29,16 +35,23 @@ func (g *ZerologGormAdapter) LogMode(newLevel logger.LogLevel) logger.Interface
|
|||
}
|
||||
return g
|
||||
}
|
||||
|
||||
// Not worth testing since only a wrapper around another function call
|
||||
func (g *ZerologGormAdapter) Info(ctx context.Context, format string, args ...any) {
|
||||
g.logger.Info().Ctx(ctx).Msgf(format, args...)
|
||||
}
|
||||
|
||||
// Not worth testing since only a wrapper around another function call
|
||||
func (g *ZerologGormAdapter) Warn(ctx context.Context, format string, args ...any) {
|
||||
g.logger.Warn().Ctx(ctx).Msgf(format, args...)
|
||||
}
|
||||
|
||||
// Not worth testing since only a wrapper around another function call
|
||||
func (g *ZerologGormAdapter) Error(ctx context.Context, format string, args ...any) {
|
||||
g.logger.Error().Ctx(ctx).Msgf(format, args...)
|
||||
}
|
||||
|
||||
// Not worth testing since only a wrapper around another function call
|
||||
func (g *ZerologGormAdapter) Trace(
|
||||
ctx context.Context,
|
||||
begin time.Time,
|
||||
|
@ -55,10 +68,12 @@ func (g *ZerologGormAdapter) Trace(
|
|||
Send()
|
||||
}
|
||||
|
||||
// Not worth testing since only a wrapper around another function call
|
||||
func (g *ZerologGormAdapter) OverwriteLoggingLevel(new zerolog.Level) {
|
||||
g.logger = g.logger.Level(new)
|
||||
}
|
||||
|
||||
// Not worth testing since only a wrapper around another function call
|
||||
func (g *ZerologGormAdapter) OverwriteLogger(new zerolog.Logger) {
|
||||
g.logger = new
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue