(t *testing.T)
| 22 | } |
| 23 | |
| 24 | func TestNewBatchHandlerDefaults(t *testing.T) { |
| 25 | h := NewBatchHandler(BatchOptions{ |
| 26 | WriteFunc: func(ctx context.Context, logs []*Log) error { |
| 27 | return nil |
| 28 | }, |
| 29 | }) |
| 30 | |
| 31 | if h.options.BatchSize != 100 { |
| 32 | t.Fatalf("Expected default BatchSize %d, got %d", 100, h.options.BatchSize) |
| 33 | } |
| 34 | |
| 35 | if h.options.Level != slog.LevelInfo { |
| 36 | t.Fatalf("Expected default Level Info, got %v", h.options.Level) |
| 37 | } |
| 38 | |
| 39 | if h.options.BeforeAddFunc != nil { |
| 40 | t.Fatal("Expected default BeforeAddFunc to be nil") |
| 41 | } |
| 42 | |
| 43 | if h.options.WriteFunc == nil { |
| 44 | t.Fatal("Expected default WriteFunc to be set") |
| 45 | } |
| 46 | |
| 47 | if h.group != "" { |
| 48 | t.Fatalf("Expected empty group, got %s", h.group) |
| 49 | } |
| 50 | |
| 51 | if len(h.attrs) != 0 { |
| 52 | t.Fatalf("Expected empty attrs, got %v", h.attrs) |
| 53 | } |
| 54 | |
| 55 | if len(h.logs) != 0 { |
| 56 | t.Fatalf("Expected empty logs queue, got %v", h.logs) |
| 57 | } |
| 58 | } |
| 59 | |
| 60 | func TestBatchHandlerEnabled(t *testing.T) { |
| 61 | h := NewBatchHandler(BatchOptions{ |
nothing calls this directly
no test coverage detected
searching dependent graphs…