gluesql_test_suite/
lib.rs

1#![deny(clippy::str_to_string)]
2
3pub mod aggregate;
4pub mod alter;
5pub mod array;
6pub mod ast_builder;
7pub mod basic;
8pub mod column_alias;
9pub mod custom_function;
10pub mod data_type;
11pub mod default;
12pub mod delete;
13pub mod dictionary;
14pub mod dictionary_index;
15pub mod distinct;
16pub mod expr;
17pub mod filter;
18pub mod foreign_key;
19pub mod function;
20pub mod index;
21pub mod inline_view;
22pub mod insert;
23pub mod join;
24pub mod like_ilike;
25pub mod limit;
26pub mod metadata;
27pub mod migrate;
28pub mod nested_select;
29pub mod nullable;
30pub mod order_by;
31pub mod ordering;
32pub mod primary_key;
33pub mod project;
34pub mod schemaless;
35pub mod series;
36pub mod show_columns;
37pub mod store;
38pub mod synthesize;
39pub mod transaction;
40pub mod type_match;
41pub mod update;
42pub mod validate;
43pub mod values;
44
45pub mod tester;
46
47pub use tester::*;
48
49#[macro_export]
50macro_rules! declare_test_fn {
51    ($test: meta, $storage: ident, $title: ident, $func: path) => {
52        #[$test]
53        async fn $title() {
54            let path = stringify!($title);
55            let storage = $storage::new(path).await;
56
57            $func(storage).await;
58        }
59    };
60}
61
62#[macro_export]
63macro_rules! generate_store_tests {
64    ($test: meta, $storage: ident) => {
65        macro_rules! glue {
66            ($title: ident, $func: path) => {
67                declare_test_fn!($test, $storage, $title, $func);
68            };
69        }
70        glue!(update, update::update);
71        glue!(insert, insert::insert);
72        glue!(delete, delete::delete);
73        glue!(basic, basic::basic);
74        glue!(array, array::array);
75        glue!(aggregate_avg, aggregate::avg::avg);
76        glue!(aggregate_count, aggregate::count::count);
77        glue!(aggregate_group_by, aggregate::group_by::group_by);
78        glue!(aggregate_max, aggregate::max::max);
79        glue!(aggregate_min, aggregate::min::min);
80        glue!(aggregate_stdev, aggregate::stdev::stdev);
81        glue!(aggregate_sum, aggregate::sum::sum);
82        glue!(aggregate_variance, aggregate::variance::variance);
83        glue!(aggregate_error, aggregate::error::error);
84        glue!(aggregate_expr, aggregate::expr::expr);
85        glue!(project, project::project);
86
87        // expression tests
88        glue!(arithmetic_error, expr::arithmetic::error::error);
89        glue!(arithmetic_project, expr::arithmetic::project::project);
90        glue!(arithmetic_on_where, expr::arithmetic::on_where::on_where);
91        glue!(bitwise_and, expr::bitwise_and::bitwise_and);
92        glue!(
93            bitwise_shift_left,
94            expr::bitwise_shift_left::bitwise_shift_left
95        );
96        glue!(
97            bitwise_shift_right,
98            expr::bitwise_shift_right::bitwise_shift_right
99        );
100        glue!(case, expr::case::case);
101        glue!(concat, expr::concat::concat);
102        glue!(expr_between, expr::between::between);
103        glue!(expr_in_list, expr::in_list::in_list);
104        glue!(expr_arrow, expr::arrow::arrow);
105        glue!(unary_operator, expr::unary_operator::unary_operator);
106
107        glue!(create_table, alter::create_table);
108        glue!(drop_table, alter::drop_table);
109        glue!(default, default::default);
110        glue!(limit, limit::limit);
111        glue!(like_ilike, like_ilike::like_ilike);
112        glue!(filter, filter::filter);
113        glue!(inline_view, inline_view::inline_view);
114        glue!(values, values::values);
115        glue!(function_upper_lower, function::upper_lower::upper_lower);
116        glue!(function_initcap, function::initcap::initcap);
117        glue!(function_gcd_lcm, function::gcd_lcm::gcd_lcm);
118        glue!(function_left_right, function::left_right::left_right);
119        glue!(function_sqrt, function::sqrt_power::sqrt);
120        glue!(function_power, function::sqrt_power::power);
121        glue!(function_lpad_rpad, function::lpad_rpad::lpad_rpad);
122        glue!(function_trim, function::trim::trim);
123        glue!(function_div_mod, function::div_mod::div_mod);
124        glue!(function_ltrim_rtrim, function::ltrim_rtrim::ltrim_rtrim);
125        glue!(function_cast_literal, function::cast::cast_literal);
126        glue!(function_cast_value, function::cast::cast_value);
127        glue!(function_coalesce, function::coalesce::coalesce);
128        glue!(function_concat, function::concat::concat);
129        glue!(function_concat_ws, function::concat_ws::concat_ws);
130        glue!(function_ifnull, function::ifnull::ifnull);
131        glue!(function_is_empty, function::is_empty::is_empty);
132        glue!(function_math_function_asin, function::math_function::asin);
133        glue!(function_math_function_acos, function::math_function::acos);
134        glue!(function_math_function_atan, function::math_function::atan);
135        glue!(function_math_function_sin, function::math_function::sin);
136        glue!(function_math_function_cos, function::math_function::cos);
137        glue!(function_math_function_tan, function::math_function::tan);
138        glue!(function_abs, function::abs::abs);
139        glue!(function_ceil, function::ceil::ceil);
140        glue!(function_round, function::round::round);
141        glue!(function_trunc, function::trunc::trunc);
142        glue!(function_rand, function::rand::rand);
143        glue!(function_floor, function::floor::floor);
144        glue!(function_format, function::format::format);
145        glue!(function_last_day, function::last_day::last_day);
146        glue!(function_ln, function::exp_log::ln);
147        glue!(function_log, function::exp_log::log);
148        glue!(function_log2, function::exp_log::log2);
149        glue!(function_log10, function::exp_log::log10);
150        glue!(function_exp, function::exp_log::exp);
151        glue!(function_now, function::now::now);
152        glue!(function_current_date, function::current_date::current_date);
153        glue!(function_current_time, function::current_time::current_time);
154        glue!(
155            function_current_timestamp,
156            function::current_timestamp::current_timestamp
157        );
158        glue!(function_sign, function::sign::sign);
159        glue!(function_skip, function::skip::skip);
160        glue!(function_to_date, function::to_date::to_date);
161        glue!(function_ascii, function::ascii::ascii);
162        glue!(function_chr, function::chr::chr);
163        glue!(function_mod, function::md5::md5);
164        glue!(function_replace, function::replace::replace);
165        glue!(function_length, function::length::length);
166        glue!(function_position, function::position::position);
167        glue!(function_find_idx, function::find_idx::find_idx);
168        glue!(function_geometry_get_x, function::geometry::get_x);
169        glue!(function_geometry_get_y, function::geometry::get_y);
170        glue!(
171            function_geometry_calc_distance,
172            function::geometry::calc_distance
173        );
174        glue!(function_add_month, function::add_month::add_month);
175        glue!(function_slice, function::slice::slice);
176        glue!(function_entries, function::entries::entries);
177        glue!(function_keys, function::keys::keys);
178        glue!(function_values, function::values::values);
179        glue!(function_nullif, function::nullif::nullif);
180        glue!(function_hex, function::hex::hex);
181        glue!(join, join::join);
182        glue!(join_project, join::project);
183        glue!(migrate, migrate::migrate);
184        glue!(nested_select, nested_select::nested_select);
185        glue!(primary_key, primary_key::primary_key);
186        glue!(foreign_key, foreign_key::foreign_key);
187        glue!(series, series::series);
188        glue!(nullable, nullable::nullable);
189        glue!(nullable_text, nullable::nullable_text);
190        glue!(nullable_implicit_insert, nullable::nullable_implicit_insert);
191        glue!(ordering, ordering::ordering);
192        glue!(order_by, order_by::order_by);
193        glue!(sql_types, data_type::sql_types::sql_types);
194        glue!(show_columns, show_columns::show_columns);
195        glue!(distinct, distinct::distinct);
196        glue!(int8, data_type::int8::int8);
197        glue!(int16, data_type::int16::int16);
198        glue!(int32, data_type::int32::int32);
199        glue!(int64, data_type::int64::int64);
200        glue!(int128, data_type::int128::int128);
201        glue!(float32, data_type::float32::float32);
202        glue!(uint16, data_type::uint16::uint16);
203        glue!(uint8, data_type::uint8::uint8);
204        glue!(uint64, data_type::uint64::uint64);
205        glue!(uint32, data_type::uint32::uint32);
206        glue!(uint128, data_type::uint128::uint128);
207        glue!(date, data_type::date::date);
208        glue!(timestamp, data_type::timestamp::timestamp);
209        glue!(time, data_type::time::time);
210        glue!(interval, data_type::interval::interval);
211        glue!(list, data_type::list::list);
212        glue!(map, data_type::map::map);
213        glue!(bytea, data_type::bytea::bytea);
214        glue!(inet, data_type::inet::inet);
215        glue!(point, data_type::point::point);
216        glue!(null, data_type::null::null);
217        glue!(synthesize, synthesize::synthesize);
218        glue!(validate_unique, validate::unique::unique);
219        glue!(validate_types, validate::types::types);
220        glue!(function_extract, function::extract::extract);
221        glue!(function_radians, function::radians::radians);
222        glue!(function_degrees, function::degrees::degrees);
223        glue!(function_pi, function::pi::pi);
224        glue!(function_reverse, function::reverse::reverse);
225        glue!(function_repeat, function::repeat::repeat);
226        glue!(function_substr, function::substr::substr);
227        glue!(uuid, data_type::uuid::uuid);
228        glue!(decimal, data_type::decimal::decimal);
229        glue!(
230            function_generate_uuid,
231            function::generate_uuid::generate_uuid
232        );
233        glue!(function_greatest, function::greatest::greatest);
234        glue!(type_match, type_match::type_match);
235        glue!(dictionary, dictionary::dictionary);
236        glue!(function_append, function::append::append);
237        glue!(function_prepend, function::prepend::prepend);
238        glue!(function_sort, function::sort::sort);
239        glue!(function_take, function::take::take);
240        glue!(column_alias, column_alias::column_alias);
241        glue!(function_splice, function::splice::splice);
242        glue!(function_dedup, function::dedup::dedup);
243
244        // ast-builder
245        glue!(ast_builder_basic, ast_builder::basic::basic);
246        glue!(
247            ast_builder_statements_queryinng_data_aggregation,
248            ast_builder::statements::querying::data_aggregation
249        );
250        glue!(
251            ast_builder_statements_queryinng_data_selection_and_projection,
252            ast_builder::statements::querying::data_selection_and_projection
253        );
254        glue!(
255            ast_builder_function_math_rounding,
256            ast_builder::function::math::rounding
257        );
258        glue!(
259            ast_builder_expr_pattern_matching,
260            ast_builder::expr::pattern_matching::pattern_matching
261        );
262        glue!(ast_builder_select, ast_builder::select::select);
263        glue!(ast_builder_values, ast_builder::values::values);
264        glue!(ast_builder_insert, ast_builder::insert::insert);
265        glue!(ast_builder_update, ast_builder::update::update);
266        glue!(ast_builder_delete, ast_builder::delete::delete);
267        glue!(ast_builder_alias_as, ast_builder::alias_as::alias_as);
268        glue!(
269            ast_builder_function_text_case_conversion,
270            ast_builder::function::text::case_conversion
271        );
272        glue!(
273            ast_builder_function_text_character_conversion,
274            ast_builder::function::text::character_conversion
275        );
276        glue!(
277            ast_builder_function_text_padding,
278            ast_builder::function::text::padding
279        );
280        glue!(
281            ast_builder_function_reference_coalesce,
282            ast_builder::function::reference::coalesce
283        );
284        glue!(
285            ast_builder_function_reference_ifnull,
286            ast_builder::function::reference::ifnull
287        );
288        glue!(
289            ast_builder_function_datetime_conversion,
290            ast_builder::function::datetime::conversion
291        );
292        glue!(
293            ast_builder_function_math_basic_arithmetic,
294            ast_builder::function::math::basic_arithmetic
295        );
296        glue!(
297            ast_builder_function_math_conversion,
298            ast_builder::function::math::conversion
299        );
300        glue!(
301            ast_builder_function_datetime_formatting,
302            ast_builder::function::datetime::formatting
303        );
304        glue!(
305            ast_builder_function_text_trimming,
306            ast_builder::function::text::trimming
307        );
308        glue!(
309            ast_builder_function_datetime_current_date_and_time,
310            ast_builder::function::datetime::current_date_and_time
311        );
312        glue!(
313            ast_builder_function_reference_current_date,
314            ast_builder::function::reference::current_date
315        );
316        glue!(
317            ast_builder_function_reference_current_time,
318            ast_builder::function::reference::current_time
319        );
320        glue!(
321            ast_builder_function_reference_current_timestamp,
322            ast_builder::function::reference::current_timestamp
323        );
324        glue!(
325            ast_builder_function_reference_generate_uuid,
326            ast_builder::function::reference::generate_uuid
327        );
328        glue!(
329            ast_builder_function_text_position_and_indexing,
330            ast_builder::function::text::position_and_indexing
331        );
332        glue!(ast_builder_index_by, ast_builder::index_by::index_by);
333        glue!(
334            ast_builder_schemaless_basic,
335            ast_builder::schemaless::basic::basic
336        );
337
338        // schemaless data support
339        glue!(schemaless_basic, schemaless::basic);
340        glue!(schemaless_error, schemaless::error);
341
342        glue!(store_insert_schema, store::insert_schema::insert_schema);
343    };
344}
345
346#[macro_export]
347macro_rules! generate_alter_table_tests {
348    ($test: meta, $storage: ident) => {
349        macro_rules! glue {
350            ($title: ident, $func: path) => {
351                declare_test_fn!($test, $storage, $title, $func);
352            };
353        }
354
355        glue!(alter_table_rename, alter::alter_table_rename);
356        glue!(alter_table_add_drop, alter::alter_table_add_drop);
357    };
358}
359
360#[macro_export]
361macro_rules! generate_custom_function_tests {
362    ($test: meta, $storage: ident) => {
363        macro_rules! glue {
364            ($title: ident, $func: path) => {
365                declare_test_fn!($test, $storage, $title, $func);
366            };
367        }
368
369        glue!(function_custom, custom_function::custom);
370    };
371}
372
373#[macro_export]
374macro_rules! generate_index_tests {
375    ($test: meta, $storage: ident) => {
376        macro_rules! glue {
377            ($title: ident, $func: path) => {
378                declare_test_fn!($test, $storage, $title, $func);
379            };
380        }
381
382        glue!(index_basic, index::basic);
383        glue!(index_and, index::and);
384        glue!(index_nested, index::nested);
385        glue!(index_null, index::null);
386        glue!(index_expr, index::expr);
387        glue!(index_value, index::value);
388        glue!(index_order_by, index::order_by);
389        glue!(index_order_by_multi, index::order_by_multi);
390        glue!(showindexes, index::showindexes);
391        glue!(dictionary_index, dictionary_index::ditionary_index);
392    };
393}
394
395#[macro_export]
396macro_rules! generate_transaction_tests {
397    ($test: meta, $storage: ident) => {
398        macro_rules! glue {
399            ($title: ident, $func: path) => {
400                declare_test_fn!($test, $storage, $title, $func);
401            };
402        }
403
404        glue!(transaction_basic, transaction::basic);
405        glue!(
406            transaction_create_drop_table,
407            transaction::create_drop_table
408        );
409        glue!(transaction_dictionary, transaction::dictionary);
410        glue!(transaction_ast_builder, transaction::ast_builder);
411    };
412}
413
414#[macro_export]
415macro_rules! generate_alter_table_index_tests {
416    ($test: meta, $storage: ident) => {
417        macro_rules! glue {
418            ($title: ident, $func: path) => {
419                declare_test_fn!($test, $storage, $title, $func);
420            };
421        }
422
423        glue!(alter_table_drop_indexed_table, alter::drop_indexed_table);
424        glue!(alter_table_drop_indexed_column, alter::drop_indexed_column);
425    };
426}
427
428#[macro_export]
429macro_rules! generate_transaction_alter_table_tests {
430    ($test: meta, $storage: ident) => {
431        macro_rules! glue {
432            ($title: ident, $func: path) => {
433                declare_test_fn!($test, $storage, $title, $func);
434            };
435        }
436
437        glue!(
438            transaction_alter_table_rename_table,
439            transaction::alter_table_rename_table
440        );
441        glue!(
442            transaction_alter_table_rename_column,
443            transaction::alter_table_rename_column
444        );
445        glue!(
446            transaction_alter_table_add_column,
447            transaction::alter_table_add_column
448        );
449        glue!(
450            transaction_alter_table_drop_column,
451            transaction::alter_table_drop_column
452        );
453    };
454}
455
456#[macro_export]
457macro_rules! generate_transaction_index_tests {
458    ($test: meta, $storage: ident) => {
459        macro_rules! glue {
460            ($title: ident, $func: path) => {
461                declare_test_fn!($test, $storage, $title, $func);
462            };
463        }
464
465        glue!(transaction_index_create, transaction::index_create);
466        glue!(transaction_index_drop, transaction::index_drop);
467    };
468}
469
470#[macro_export]
471macro_rules! generate_metadata_table_tests {
472    ($test: meta, $storage: ident) => {
473        macro_rules! glue {
474            ($title: ident, $func: path) => {
475                declare_test_fn!($test, $storage, $title, $func);
476            };
477        }
478
479        glue!(metadata_table, metadata::table::table);
480    };
481}
482
483#[macro_export]
484macro_rules! generate_metadata_index_tests {
485    ($test: meta, $storage: ident) => {
486        macro_rules! glue {
487            ($title: ident, $func: path) => {
488                declare_test_fn!($test, $storage, $title, $func);
489            };
490        }
491
492        glue!(metadata_index, metadata::index::index);
493    };
494}