(t *testing.T)
| 58 | } |
| 59 | |
| 60 | func TestBatchHandlerEnabled(t *testing.T) { |
| 61 | h := NewBatchHandler(BatchOptions{ |
| 62 | Level: slog.LevelWarn, |
| 63 | WriteFunc: func(ctx context.Context, logs []*Log) error { |
| 64 | return nil |
| 65 | }, |
| 66 | }) |
| 67 | |
| 68 | l := slog.New(h) |
| 69 | |
| 70 | scenarios := []struct { |
| 71 | level slog.Level |
| 72 | expected bool |
| 73 | }{ |
| 74 | {slog.LevelDebug, false}, |
| 75 | {slog.LevelInfo, false}, |
| 76 | {slog.LevelWarn, true}, |
| 77 | {slog.LevelError, true}, |
| 78 | } |
| 79 | |
| 80 | for _, s := range scenarios { |
| 81 | t.Run(fmt.Sprintf("Level %v", s.level), func(t *testing.T) { |
| 82 | result := l.Enabled(context.Background(), s.level) |
| 83 | |
| 84 | if result != s.expected { |
| 85 | t.Fatalf("Expected %v, got %v", s.expected, result) |
| 86 | } |
| 87 | }) |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | func TestBatchHandlerSetLevel(t *testing.T) { |
| 92 | h := NewBatchHandler(BatchOptions{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…