TestFunctionsConditional tests conditional functions
(t *testing.T)
| 328 | |
| 329 | // TestFunctionsConditional tests conditional functions |
| 330 | func 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 |
| 354 | func TestFunctionsMisc(t *testing.T) { |
nothing calls this directly
no test coverage detected