soda-core
soda-core copied to clipboard
Improve test readability
The goal is to make the tests more readable. They became unreadable when we added the formatting based on the data source default behavior.
Schema checks use complicated way to build the checks with appropriate columns case (i.e. lowercase for pg, upper for snowflake). This hinders readability. Come up with a way that will put easy readability back but still take care of the case manipulation.
checks_str = format_checks(
[("id", "varchar"), ("distance", "integer")],
indent=15,
data_source=scanner.data_source,
)
scan.add_sodacl_yaml_str(
f"""
checks for {table_name}:
- schema:
fail:
when wrong column type:
{checks_str}
"""
)
Desirable state (roughly):
scan.add_sodacl_yaml_str(
f"""
checks for {table_name}:
- schema:
fail:
when wrong column type:
- id: varchar
- distance: integer
""".format_for_datasource(data_source)
)