MCPcopy
hub / github.com/pocketbase/pocketbase / TestBatchHandlerEnabled

Function TestBatchHandlerEnabled

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

Source from the content-addressed store, hash-verified

58}
59
60func 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
91func TestBatchHandlerSetLevel(t *testing.T) {
92 h := NewBatchHandler(BatchOptions{

Callers

nothing calls this directly

Calls 3

NewBatchHandlerFunction · 0.85
EnabledMethod · 0.80
RunMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…