MCPcopy
hub / github.com/pocketbase/pocketbase / TestNewBatchHandlerDefaults

Function TestNewBatchHandlerDefaults

tools/logger/batch_handler_test.go:24–58  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

22}
23
24func 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
60func TestBatchHandlerEnabled(t *testing.T) {
61 h := NewBatchHandler(BatchOptions{

Callers

nothing calls this directly

Calls 1

NewBatchHandlerFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…