MCPcopy Create free account
hub / github.com/PostHog/duckgres / TestQueryLoggerStopIsIdempotent

Function TestQueryLoggerStopIsIdempotent

server/querylog_test.go:162–183  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

160 // Create a logger with a tiny channel to test non-blocking behavior
161 ql := &QueryLogger{
162 ch: make(chan QueryLogEntry, 1),
163 cfg: QueryLogConfig{BatchSize: 1000},
164 done: make(chan struct{}),
165 }
166
167 // Fill the channel
168 ql.ch <- QueryLogEntry{EventTime: time.Now(), Query: "first"}
169
170 // This should not block
171 done := make(chan bool, 1)
172 go func() {
173 ql.Log(QueryLogEntry{EventTime: time.Now(), Query: "second"})
174 done <- true
175 }()
176
177 select {
178 case <-done:
179 // Success - Log returned without blocking
180 case <-time.After(100 * time.Millisecond):
181 t.Error("Log() blocked when channel was full")
182 }
183}
184
185func TestQueryLoggerStopIsIdempotent(t *testing.T) {
186 db, err := sql.Open("duckdb", ":memory:")

Callers

nothing calls this directly

Calls 3

flushLoopMethod · 0.95
StopMethod · 0.95
OpenMethod · 0.45

Tested by

no test coverage detected