-
Notifications
You must be signed in to change notification settings - Fork 15
Testing with EUnit
walter-weinmann edited this page May 12, 2020
·
10 revisions
- ALTER
- BEGIN and CALL
- CLOSE, COMMIT, OPEN, ROLLBACK and WHENEVER
- CREATE
- CURSOR Statements
- DELETE
- DROP
- FETCH
- GRANT
- INSERT
- INTERSECT, MINUS, UNION and UNION ALL
- JSON Path
- LEXX
- Multiple Statements
- REVOKE
- SCHEMA
- SELECT
- TRUNCATE
- UPDATE
- VIEW
All the test cases are also documentation of the current support.
-
SET SOURCEFILES=<test>
and run withrebar3 eunit skip_deps=true
one specific<test>.tst
file from thetest/eunit.
folder.
The sqlparse_adhoc_test
module can be used for spontaneous tests during the development process. The SQL statements to be tested must be stored in the sqlparse_adhoc_test.tst
file, for example
"select column_1 from table_1".
The LOPTS
and TEST_VERSION
macros can be used to modify the tests as follows:
I. LOPTS
The formatting options that deviate from the standard can be defined here, for example:
-define(LOPTS, [
{case_identifier, init_cap},
{line_break_after, 0}
]).
II. TEST_VERSION
-
bottom_up
- uses the methodsqlparse_layout:bottom_up/1
-
check
- compares the results of using first the methodsqlparse_layout:top_down/1
and then the methodsqlparse_layout:bottom_up/1
-
flat
(default value) - uses the methodsqlparse_layout:flat/1
-
full
- uses the methodsqlparse_test_utils:eunit_test/1
-
pretty
- uses the methodsqlparse_layout:pretty/2
-
top_down
- uses the methodsqlparse_layout:top_down/1
TEST_VERSION
full
includes the following steps:
- Create the parse tree and the token list of the given SQL statements.
- Create top down the flat version of the SQL statement based the parse tree from step 1 (applying custom fold extension
sqlparse_format_flat
). - Create the parse tree and the token list from the SQL statement from step 2.
- Check that the parse trees from step 1 and step 3 are identical.
- Check that the SQL statement from step 2 does not have two or more consecutive blanks at any point.
- Create the top down result with custom fold extension
sqlparse_check_td_vs_bu
. - Create the bottom up result with custom fold extension
sqlparse_check_td_vs_bu
. - Check that the results from step 6 and step 7 are identical.
- Create top down the formatted version of the SQL statement based the parse tree from step 1 (applying custom fold extension
sqlparse_format_pretty
). - Create the parse tree from the SQL statement from step 9.
- Check that the lower-case versions of the parse trees from step 1 and step 10 are identical.
The file sqlparse_pretty_test.hrl
contains the test cases for the custom fold extension sqlparse_format_pretty
.