Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save portovep/c3515d1f7f76de2c08b491f2c3e3cd4d to your computer and use it in GitHub Desktop.
Save portovep/c3515d1f7f76de2c08b491f2c3e3cd4d to your computer and use it in GitHub Desktop.
Example of a dbt unit test
{{ 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