Test FunctionCall node
(t *testing.T)
| 851 | |
| 852 | // Test FunctionCall node |
| 853 | func TestFunctionCall(t *testing.T) { |
| 854 | tests := []struct { |
| 855 | name string |
| 856 | funcCall *FunctionCall |
| 857 | wantLiteral string |
| 858 | wantChildren int |
| 859 | }{ |
| 860 | { |
| 861 | name: "COUNT(*) function", |
| 862 | funcCall: &FunctionCall{ |
| 863 | Name: "COUNT", |
| 864 | Arguments: []Expression{&Identifier{Name: "*"}}, |
| 865 | }, |
| 866 | wantLiteral: "COUNT", |
| 867 | wantChildren: 1, |
| 868 | }, |
| 869 | { |
| 870 | name: "SUM function with column", |
| 871 | funcCall: &FunctionCall{ |
| 872 | Name: "SUM", |
| 873 | Arguments: []Expression{&Identifier{Name: "amount"}}, |
| 874 | }, |
| 875 | wantLiteral: "SUM", |
| 876 | wantChildren: 1, |
| 877 | }, |
| 878 | { |
| 879 | name: "window function with OVER clause", |
| 880 | funcCall: &FunctionCall{ |
| 881 | Name: "ROW_NUMBER", |
| 882 | Arguments: []Expression{}, |
| 883 | Over: &WindowSpec{Name: "w"}, |
| 884 | }, |
| 885 | wantLiteral: "ROW_NUMBER", |
| 886 | wantChildren: 1, |
| 887 | }, |
| 888 | { |
| 889 | name: "function with multiple arguments", |
| 890 | funcCall: &FunctionCall{ |
| 891 | Name: "COALESCE", |
| 892 | Arguments: []Expression{ |
| 893 | &Identifier{Name: "email"}, |
| 894 | &LiteralValue{Value: "N/A"}, |
| 895 | }, |
| 896 | }, |
| 897 | wantLiteral: "COALESCE", |
| 898 | wantChildren: 2, |
| 899 | }, |
| 900 | } |
| 901 | |
| 902 | for _, tt := range tests { |
| 903 | tt := tt // G601: Create local copy to avoid memory aliasing |
| 904 | t.Run(tt.name, func(t *testing.T) { |
| 905 | // Test TokenLiteral |
| 906 | if got := tt.funcCall.TokenLiteral(); got != tt.wantLiteral { |
| 907 | t.Errorf("FunctionCall.TokenLiteral() = %v, want %v", got, tt.wantLiteral) |
| 908 | } |
| 909 | |
| 910 | // Test Children |
nothing calls this directly
no test coverage detected