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

Function TestIsEmptyQuery

server/conn_test.go:61–93  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

59 }
60}
61
62func TestIsEmptyQuery(t *testing.T) {
63 tests := []struct {
64 name string
65 query string
66 expected bool
67 }{
68 {"empty string", "", true},
69 {"single semicolon", ";", true},
70 {"multiple semicolons", ";;;", true},
71 {"semicolons with spaces", "; ; ;", true},
72 {"semicolons with tabs", ";\t;\t;", true},
73 {"semicolons with newlines", ";\n;\n;", true},
74 {"only whitespace", " \t\n", true},
75 {"line comment only", "-- ping", true},
76 {"line comment with newline", "-- ping\n", true},
77 {"block comment only", "/* comment */", true},
78 {"block comment then semicolons", "/* comment */;", true},
79 {"comment then query", "-- comment\nSELECT 1", false},
80 {"block comment then query", "/* comment */SELECT 1", false},
81 {"SELECT query", "SELECT 1", false},
82 {"SELECT with semicolon", "SELECT 1;", false},
83 {"semicolon then query", ";SELECT 1", false},
84 }
85
86 for _, tt := range tests {
87 t.Run(tt.name, func(t *testing.T) {
88 result := isEmptyQuery(tt.query)
89 if result != tt.expected {
90 t.Errorf("isEmptyQuery(%q) = %v, want %v", tt.query, result, tt.expected)
91 }
92 })
93 }
94}
95
96func TestStripLeadingComments(t *testing.T) {

Callers

nothing calls this directly

Calls 2

isEmptyQueryFunction · 0.85
RunMethod · 0.65

Tested by

no test coverage detected