soda-core icon indicating copy to clipboard operation
soda-core copied to clipboard

Improve test readability

Open m1n0 opened this issue 3 years ago • 0 comments

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.

Current state:

    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)
    )

m1n0 avatar Mar 28 '22 18:03 m1n0