MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / TestExtractFunctions_SimpleFunction

Function TestExtractFunctions_SimpleFunction

pkg/gosqlx/extract_test.go:451–462  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

449}
450
451func TestExtractFunctions_SimpleFunction(t *testing.T) {
452 sql := "SELECT COUNT(*) FROM users"
453 astNode, err := Parse(sql)
454 if err != nil {
455 t.Fatalf("Failed to parse SQL: %v", err)
456 }
457
458 functions := ExtractFunctions(astNode)
459 if len(functions) != 1 || !contains(functions, "COUNT") {
460 t.Errorf("Expected 'COUNT' function, got: %v", functions)
461 }
462}
463
464func TestExtractFunctions_MultipleFunctions(t *testing.T) {
465 sql := "SELECT COUNT(*), AVG(salary), MAX(age), MIN(created_at) FROM users"

Callers

nothing calls this directly

Calls 5

ParseFunction · 0.85
ExtractFunctionsFunction · 0.85
containsFunction · 0.70
FatalfMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected