diff --git a/README.md b/README.md index 4e27fb1..42402df 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ You can test models independently by mocking their dependencies (models, sources - [Main Features](#main-features) - [Documentation](#documentation) - [Anatomy of a test](#anatomy-of-a-test) + - [Running Tests](#running-tests) - [Available Macros](#available-macros) - [Test Examples](#test-examples) - [Different ways to build mock values](#different-ways-to-build-mock-values) diff --git a/integration-tests/models/model_ephemeral.sql b/integration-tests/models/model_ephemeral.sql new file mode 100644 index 0000000..ee2dbfd --- /dev/null +++ b/integration-tests/models/model_ephemeral.sql @@ -0,0 +1,3 @@ +{{ config (materialized = 'incremental' ) }} + +select 1 as a, 'b' as b \ No newline at end of file diff --git a/integration-tests/models/model_references_ephemeral.sql b/integration-tests/models/model_references_ephemeral.sql new file mode 100644 index 0000000..94f3f79 --- /dev/null +++ b/integration-tests/models/model_references_ephemeral.sql @@ -0,0 +1 @@ +select * from {{ dbt_unit_testing.ref('model_ephemeral') }} where a >= 1 diff --git a/integration-tests/tests/unit/model_references_ephemeral.sql b/integration-tests/tests/unit/model_references_ephemeral.sql new file mode 100644 index 0000000..88d92a0 --- /dev/null +++ b/integration-tests/tests/unit/model_references_ephemeral.sql @@ -0,0 +1,16 @@ +{{ + config( + tags=['unit-test', 'bigquery', 'snowflake', 'postgres'] + ) +}} + +{% call dbt_unit_testing.test('model_ephemeral', 'sample test') %} + {% call dbt_unit_testing.mock_ref ('model_a') %} + select 0 as a, 'a' as b + UNION ALL + select 1 as a, 'b' as b + {% endcall %} + {% call dbt_unit_testing.expect() %} + select 1 as a, 'b' as b + {% endcall %} +{% endcall %} \ No newline at end of file diff --git a/macros/utils.sql b/macros/utils.sql index b16a83c..9629273 100644 --- a/macros/utils.sql +++ b/macros/utils.sql @@ -19,6 +19,7 @@ {% endmacro %} {% macro extract_columns_difference(cl1, cl2) %} + !! WRONG !! {% set columns = cl1 | reject('in', cl2) | list %} {{ return(columns) }} {% endmacro %}