|
1 | 1 | {% macro test(model_name, test_description='(no description)', options={}) %} |
2 | 2 | {{ dbt_unit_testing.ref_tested_model(model_name) }} |
3 | 3 |
|
4 | | - {% if execute and flags.WHICH == 'test' %} |
5 | | - {{ dbt_unit_testing.set_test_context("is_incremental_should_be_true_for_this_model", "") }} |
6 | | - {% set mocks_and_expectations_json_str = caller() %} |
7 | | - {% set model_version = kwargs["version"] | default(kwargs["v"]) | default(none) %} |
8 | | - {% set model_node = {"package_name": model.package_name, "name": model_name, "version": model_version} %} |
9 | | - {% set test_configuration, test_queries = dbt_unit_testing.build_configuration_and_test_queries(model_node, test_description, options, mocks_and_expectations_json_str) %} |
10 | | - {% set test_report = dbt_unit_testing.build_test_report(test_configuration, test_queries) %} |
11 | | - |
12 | | - {% if not test_report.succeeded %} |
13 | | - {{ dbt_unit_testing.show_test_report(test_configuration, test_report) }} |
| 4 | + {% if execute %} |
| 5 | + {% if flags.WHICH == 'test' %} |
| 6 | + {{ dbt_unit_testing.set_test_context("is_incremental_should_be_true_for_this_model", "") }} |
| 7 | + {% set mocks_and_expectations_json_str = caller() %} |
| 8 | + {% set model_version = kwargs["version"] | default(kwargs["v"]) | default(none) %} |
| 9 | + {% set model_node = {"package_name": model.package_name, "name": model_name, "version": model_version} %} |
| 10 | + {% set test_configuration, test_queries = dbt_unit_testing.build_configuration_and_test_queries(model_node, test_description, options, mocks_and_expectations_json_str) %} |
| 11 | + {% set test_report = dbt_unit_testing.build_test_report(test_configuration, test_queries) %} |
| 12 | + |
| 13 | + {% if not test_report.succeeded %} |
| 14 | + {{ dbt_unit_testing.show_test_report(test_configuration, test_report) }} |
| 15 | + {% endif %} |
| 16 | + |
| 17 | + select 1 as a from (select 1) as t where {{ not test_report.succeeded }} |
| 18 | + {{ dbt_unit_testing.clear_test_context() }} |
| 19 | + {% else %} |
| 20 | + select 1 as a from (select 1) as t where false |
14 | 21 | {% endif %} |
15 | | - |
16 | | - select 1 as a from (select 1) as t where {{ not test_report.succeeded }} |
17 | | - {{ dbt_unit_testing.clear_test_context() }} |
18 | 22 | {% endif %} |
19 | 23 | {% endmacro %} |
20 | 24 |
|
|
0 commit comments