Closed darian-heede closed 11 months ago
You can define a variable with the value of your mock, like this:
{% set mock_a %}
{% call dbt_unit_testing.mock_ref('mock-a') %}
...
{% endcall %}
{% endset %}
{% call dbt_unit_testing.test('test-a', 'Test A') %}
{{ mock_a }}
{% call dbt_unit_testing.mock_ref('mock-b') %}
...
{% endcall %}
{% call dbt_unit_testing.expect() %}
...
{% endcall %}
{% endcall %}
UNION ALL
{% call dbt_unit_testing.test('test-b', 'Test B') %}
{{ mock_a }}
{% call dbt_unit_testing.mock_ref('mock-c') %}
...
{% endcall %}
{% call dbt_unit_testing.expect() %}
...
{% endcall %}
{% endcall %}
Hope it helps
Hi @psousa50 , this is exactly what I was looking for, thanks!
Hi there,
first off, I would like to thank you for this great package!
Is there a way of reusing a mock-ref for multiple unit-tests combined using
UNION ALL
without having to set it in everydbt_unit_testing.test()
call?The following example reuses the mock-ref mock-a in both unit tests:
It would be great not having to repeat the mock-a definition for every unit test.