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

Function TestLogQueryStartedEmitsQueryInitiated

server/conn_analytics_test.go:34–53  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

32 t.Cleanup(func() { analytics.SetDefault(nil) })
33 return fake
34}
35
36func TestLogClientQueryReceivedEmitsQueryInitiated(t *testing.T) {
37 fake := installFakeQueryTracker(t)
38 c := &clientConn{orgID: "acme", username: "root", teamID: 42, applicationName: "psql", ctx: context.Background()}
39
40 c.logClientQueryReceived(context.Background(), "simple", "SELECT 1")
41
42 if len(fake.events) != 1 {
43 t.Fatalf("expected 1 event, got %d", len(fake.events))
44 }
45 e := fake.events[0]
46 if e.event != "query_initiated" {
47 t.Errorf("event = %q, want query_initiated", e.event)
48 }
49 if e.orgID != "acme" {
50 t.Errorf("orgID = %q, want acme", e.orgID)
51 }
52 if e.props["user"] != "root" {
53 t.Errorf("user = %v, want root", e.props["user"])
54 }
55 if e.props["team_id"] != int64(42) {
56 t.Errorf("team_id = %v, want 42", e.props["team_id"])

Callers

nothing calls this directly

Calls 2

logQueryStartedMethod · 0.95
installFakeQueryTrackerFunction · 0.85

Tested by

no test coverage detected