[feature] migrate to monorepo
This commit is contained in:
commit
05ddc1f783
267 changed files with 75165 additions and 0 deletions
85
backend/pkg/logger/logger_test.go
Normal file
85
backend/pkg/logger/logger_test.go
Normal file
|
@ -0,0 +1,85 @@
|
|||
package logger
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"tss-rocks-be/internal/config"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
)
|
||||
|
||||
func TestSetup(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
config *config.Config
|
||||
expectedLevel zerolog.Level
|
||||
}{
|
||||
{
|
||||
name: "Debug level",
|
||||
config: &config.Config{
|
||||
Logging: struct {
|
||||
Level string `yaml:"level"`
|
||||
Format string `yaml:"format"`
|
||||
}{
|
||||
Level: "debug",
|
||||
Format: "json",
|
||||
},
|
||||
},
|
||||
expectedLevel: zerolog.DebugLevel,
|
||||
},
|
||||
{
|
||||
name: "Info level",
|
||||
config: &config.Config{
|
||||
Logging: struct {
|
||||
Level string `yaml:"level"`
|
||||
Format string `yaml:"format"`
|
||||
}{
|
||||
Level: "info",
|
||||
Format: "json",
|
||||
},
|
||||
},
|
||||
expectedLevel: zerolog.InfoLevel,
|
||||
},
|
||||
{
|
||||
name: "Error level",
|
||||
config: &config.Config{
|
||||
Logging: struct {
|
||||
Level string `yaml:"level"`
|
||||
Format string `yaml:"format"`
|
||||
}{
|
||||
Level: "error",
|
||||
Format: "json",
|
||||
},
|
||||
},
|
||||
expectedLevel: zerolog.ErrorLevel,
|
||||
},
|
||||
{
|
||||
name: "Invalid level defaults to Info",
|
||||
config: &config.Config{
|
||||
Logging: struct {
|
||||
Level string `yaml:"level"`
|
||||
Format string `yaml:"format"`
|
||||
}{
|
||||
Level: "invalid",
|
||||
Format: "json",
|
||||
},
|
||||
},
|
||||
expectedLevel: zerolog.InfoLevel,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
Setup(tt.config)
|
||||
if zerolog.GlobalLevel() != tt.expectedLevel {
|
||||
t.Errorf("Setup() set level to %v, want %v", zerolog.GlobalLevel(), tt.expectedLevel)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetLogger(t *testing.T) {
|
||||
logger := GetLogger()
|
||||
if logger == nil {
|
||||
t.Error("GetLogger() returned nil")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue