| Conditions | 3 |
| Total Lines | 40 |
| Code Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | package config_test |
||
| 11 | func TestLogConfig_GetSlogLevel(t *testing.T) { |
||
| 12 | tests := []struct { |
||
| 13 | name string |
||
| 14 | level string |
||
| 15 | expected slog.Level |
||
| 16 | }{ |
||
| 17 | { |
||
| 18 | name: "DebugLevel", |
||
| 19 | level: "debug", |
||
| 20 | expected: slog.LevelDebug, |
||
| 21 | }, |
||
| 22 | { |
||
| 23 | name: "InfoLevel", |
||
| 24 | level: "info", |
||
| 25 | expected: slog.LevelInfo, |
||
| 26 | }, |
||
| 27 | { |
||
| 28 | name: "WarnLevel", |
||
| 29 | level: "warn", |
||
| 30 | expected: slog.LevelWarn, |
||
| 31 | }, |
||
| 32 | { |
||
| 33 | name: "ErrorLevel", |
||
| 34 | level: "error", |
||
| 35 | expected: slog.LevelError, |
||
| 36 | }, |
||
| 37 | { |
||
| 38 | name: "DefaultLevel", |
||
| 39 | level: "unknown", |
||
| 40 | expected: slog.LevelInfo, |
||
| 41 | }, |
||
| 42 | } |
||
| 43 | |||
| 44 | for _, tt := range tests { |
||
| 45 | t.Run(tt.name, func(t *testing.T) { |
||
| 46 | logConfig := config.LogConfig{ |
||
| 47 | Level: tt.level, |
||
| 48 | } |
||
| 49 | actual := logConfig.GetSlogLevel() |
||
| 50 | assert.Equal(t, tt.expected, actual) |
||
| 51 | }) |
||
| 54 |