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

Function TestLogQueryErrorCapturesPlainQuery

server/recent_errors_test.go:82–96  ·  view source on GitHub ↗

A non-secret query is stored verbatim (redaction is a no-op) so triage keeps full fidelity for ordinary errors.

(t *testing.T)

Source from the content-addressed store, hash-verified

80// A non-secret query is stored verbatim (redaction is a no-op) so triage keeps
81// full fidelity for ordinary errors.
82func TestLogQueryErrorCapturesPlainQuery(t *testing.T) {
83 installFakeQueryTracker(t)
84 s := &Server{recentErrors: newRecentErrorRing(0)}
85 c := &clientConn{server: s, orgID: "acme", username: "root", ctx: context.Background()}
86
87 c.logQueryError("SELECT * FROM nope", errors.New("Catalog Error: Table with name nope does not exist!"))
88
89 got := s.RecentErrors(10)
90 if len(got) != 1 || got[0].Query != "SELECT * FROM nope" {
91 t.Fatalf("plain query not captured verbatim: %+v", got)
92 }
93 if got[0].Category != "user" {
94 t.Errorf("category = %q, want user (Catalog Error)", got[0].Category)
95 }
96}

Callers

nothing calls this directly

Calls 4

logQueryErrorMethod · 0.95
RecentErrorsMethod · 0.95
installFakeQueryTrackerFunction · 0.85
newRecentErrorRingFunction · 0.85

Tested by

no test coverage detected