Generate a TD header for a SQL feature test scenario.
(test_name: str, drop_schema: bool)
| 39 | |
| 40 | |
| 41 | def header(test_name: str, drop_schema: bool) -> str: |
| 42 | """Generate a TD header for a SQL feature test scenario.""" |
| 43 | header = dedent(f""" |
| 44 | # Feature test for SQL feature test: {test_name} |
| 45 | #####################################{'#' * len(test_name)} |
| 46 | """) |
| 47 | # Re-create schema (optional). |
| 48 | if drop_schema: |
| 49 | header += dedent(f""" |
| 50 | $ postgres-execute connection=postgres://mz_system@materialized:6877/materialize |
| 51 | DROP SCHEMA IF EXISTS public CASCADE; |
| 52 | CREATE SCHEMA public /* {test_name} */; |
| 53 | GRANT ALL PRIVILEGES ON SCHEMA public TO materialize; |
| 54 | """) |
| 55 | # Create connections. |
| 56 | header += dedent(f""" |
| 57 | $ postgres-connect name=user url={USER_CONNECTION_URL} |
| 58 | $ postgres-connect name=mz_system url={MZ_SYSTEM_CONNECTION_URL} |
| 59 | """) |
| 60 | return header.strip() |
| 61 | |
| 62 | |
| 63 | def statement_error(statement: str, error_msg: str) -> str: |