(t *testing.T)
| 842 | } |
| 843 | |
| 844 | func TestBuildPartitionClauses(t *testing.T) { |
| 845 | const ( |
| 846 | dbName = "test" |
| 847 | tbName = "t" |
| 848 | fields = "*" |
| 849 | partition = "p0" |
| 850 | where = "WHERE a > 10" |
| 851 | orderByClause = "ORDER BY a" |
| 852 | ) |
| 853 | testCases := []struct { |
| 854 | partition string |
| 855 | where string |
| 856 | orderByClause string |
| 857 | expectedQuery string |
| 858 | }{ |
| 859 | { |
| 860 | "", |
| 861 | "", |
| 862 | "", |
| 863 | "SELECT * FROM `test`.`t`", |
| 864 | }, |
| 865 | { |
| 866 | partition, |
| 867 | "", |
| 868 | "", |
| 869 | "SELECT * FROM `test`.`t` PARTITION(`p0`)", |
| 870 | }, |
| 871 | { |
| 872 | partition, |
| 873 | where, |
| 874 | "", |
| 875 | "SELECT * FROM `test`.`t` PARTITION(`p0`) WHERE a > 10", |
| 876 | }, |
| 877 | { |
| 878 | partition, |
| 879 | "", |
| 880 | orderByClause, |
| 881 | "SELECT * FROM `test`.`t` PARTITION(`p0`) ORDER BY a", |
| 882 | }, |
| 883 | { |
| 884 | partition, |
| 885 | where, |
| 886 | orderByClause, |
| 887 | "SELECT * FROM `test`.`t` PARTITION(`p0`) WHERE a > 10 ORDER BY a", |
| 888 | }, |
| 889 | { |
| 890 | "", |
| 891 | where, |
| 892 | orderByClause, |
| 893 | "SELECT * FROM `test`.`t` WHERE a > 10 ORDER BY a", |
| 894 | }, |
| 895 | } |
| 896 | for _, testCase := range testCases { |
| 897 | query := buildSelectQuery(dbName, tbName, fields, testCase.partition, testCase.where, testCase.orderByClause) |
| 898 | require.Equal(t, testCase.expectedQuery, query) |
| 899 | } |
| 900 | } |
| 901 |
nothing calls this directly
no test coverage detected