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

Function TestFunctionsConditional

tests/integration/functions_test.go:330–351  ·  view source on GitHub ↗

TestFunctionsConditional tests conditional functions

(t *testing.T)

Source from the content-addressed store, hash-verified

328
329// TestFunctionsConditional tests conditional functions
330func TestFunctionsConditional(t *testing.T) {
331 tests := []QueryTest{
332 // CASE
333 {Name: "case_when", Query: "SELECT CASE WHEN 1 > 0 THEN 'positive' WHEN 1 < 0 THEN 'negative' ELSE 'zero' END"},
334 {Name: "case_simple", Query: "SELECT CASE 1 WHEN 1 THEN 'one' WHEN 2 THEN 'two' ELSE 'other' END"},
335 {Name: "case_in_select", Query: "SELECT name, CASE WHEN active THEN 'active' ELSE 'inactive' END AS status FROM users LIMIT 5"},
336
337 // COALESCE
338 {Name: "coalesce_null", Query: "SELECT COALESCE(NULL, 'default')"},
339 {Name: "coalesce_value", Query: "SELECT COALESCE('value', 'default')"},
340 {Name: "coalesce_multiple", Query: "SELECT COALESCE(NULL, NULL, 'third')"},
341
342 // NULLIF
343 {Name: "nullif_equal", Query: "SELECT NULLIF(1, 1)"},
344 {Name: "nullif_different", Query: "SELECT NULLIF(1, 2)"},
345
346 // GREATEST/LEAST
347 {Name: "greatest", Query: "SELECT GREATEST(1, 5, 3)"},
348 {Name: "least", Query: "SELECT LEAST(1, 5, 3)"},
349 }
350 runQueryTests(t, tests)
351}
352
353// TestFunctionsMisc tests miscellaneous functions
354func TestFunctionsMisc(t *testing.T) {

Callers

nothing calls this directly

Calls 1

runQueryTestsFunction · 0.85

Tested by

no test coverage detected