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

Function TestNormalizeIdleTimeout

server/server_test.go:16–33  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

14 "testing"
15 "time"
16)
17
18func TestCancelQueryDoesNotLogSecretKey(t *testing.T) {
19 var logs bytes.Buffer
20 previousLogger := slog.Default()
21 slog.SetDefault(slog.New(slog.NewTextHandler(&logs, &slog.HandlerOptions{Level: slog.LevelDebug})))
22 t.Cleanup(func() { slog.SetDefault(previousLogger) })
23
24 key := BackendKey{Pid: 42, SecretKey: 987654321}
25 s := &Server{activeQueries: map[BackendKey]context.CancelFunc{key: func() {}}}
26 if !s.CancelQuery(key) {
27 t.Fatal("CancelQuery returned false for a registered key")
28 }
29 if strings.Contains(logs.String(), "987654321") {
30 t.Fatalf("cancel secret key leaked to logs: %s", logs.String())
31 }
32}
33
34// TestDefaultControlPlaneIdleTimeout pins the control-plane idle-timeout
35// default. The value is a product decision, not an implementation detail: it
36// decides whether a client that pauses between statements keeps its connection.

Callers

nothing calls this directly

Calls 1

NormalizeIdleTimeoutFunction · 0.85

Tested by

no test coverage detected