Created
May 31, 2023 07:22
-
-
Save portovep/c3515d1f7f76de2c08b491f2c3e3cd4d to your computer and use it in GitHub Desktop.
Example of a dbt unit test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{{ config(tags=['unit-test', 'unit-tests']) }} | |
{% call dbt_unit_testing.test ('int_weight_measurements_with_latest_height', | |
'it should enrich weight measurement with latest height measurement') %} | |
{% call dbt_unit_testing.mock_ref ('stg_gym_app__weight') %} | |
select | |
to_date('2022-09-01', 'YYYY-MM-DD') as created_date, | |
1 as user_id, | |
82.50 as weight | |
{% endcall %} | |
{% call dbt_unit_testing.mock_ref ('stg_gym_app__height') %} | |
select | |
to_date('2021-07-01', 'YYYY-MM-DD') as created_date, | |
1 as user_id, | |
182 as height | |
UNION ALL | |
select | |
to_date('2022-08-01', 'YYYY-MM-DD') as created_date, | |
1 as user_id, | |
183 as height | |
{% endcall %} | |
{% call dbt_unit_testing.expect() %} | |
select | |
to_date('2022/09/01', 'YYYY-MM-DD') as created_date, | |
1 as user_id, | |
82.50 as weight, | |
183 as height | |
{% endcall %} | |
{% endcall %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment