3 ms·
We use this and take an example-based tests approach for any non-trivial DBT models: https://github.com/EqualExperts/dbt-unit-testing https://github.com/EqualEx
by epgui 4y ago
We use this and take an example-based tests approach for any non-trivial DBT models: https://github.com/EqualExperts/dbt-unit-testing https://github.com/EqualExperts/dbt-unit-testing
More trivial example:
{%
call dbt_unit_testing.test(
'REDACTED',
'Should replace nullish values with NULL'
)
%}
{% call dbt_unit_testing.mock_source('REDACTED', 'REDACTED', opts) %}
"id" | "industry"
1 | 'A'
2 | 'B'
3 | ''
4 | 'Other'
5 | 'C'
6 | NULL
{% endcall %}
{% call dbt_unit_testing.expect(opts) %}
"history_id" | "REDACTED"
1 | 'A'
2 | 'B'
3 | NULL
4 | NULL
5 | 'C'
6 | NULL
{% endcall %}
{% endcall %}