From 5e9553dc08e74eecf5ed993ec9876d669293e99b Mon Sep 17 00:00:00 2001 From: alexzorin Date: Tue, 23 Jul 2024 21:29:51 +1000 Subject: [PATCH] `test` macro: set `model_node_being_tested` before `caller()` (#218) --- macros/tests.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/macros/tests.sql b/macros/tests.sql index 6b960a6..115b617 100644 --- a/macros/tests.sql +++ b/macros/tests.sql @@ -4,10 +4,10 @@ {% if execute %} {% if flags.WHICH in ('test', 'build') %} {{ dbt_unit_testing.set_test_context("is_incremental_should_be_true_for_this_model", "") }} - {% set mocks_and_expectations_json_str = caller() %} {% set model_version = kwargs["version"] | default(kwargs["v"]) | default(none) %} {% set model_node = {"package_name": model.package_name, "name": model_name, "version": model_version} %} {{ dbt_unit_testing.set_test_context("model_node_being_tested", model_node) }} + {% set mocks_and_expectations_json_str = caller() %} {% set test_configuration, test_queries = dbt_unit_testing.build_configuration_and_test_queries(model_node, test_description, options, mocks_and_expectations_json_str) %} {% set test_report = dbt_unit_testing.build_test_report(test_configuration, test_queries) %}