Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
psousa50 committed Aug 3, 2023
1 parent e52582b commit c997099
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{% if dbt_unit_testing.version_bigger_or_equal_to("1.5") %}
{% if dbt_unit_testing.version_bigger_or_equal_to("1.5.0") %}
select * from {{ ref('model_with_version') }} where a > 0
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{% if dbt_unit_testing.version_bigger_or_equal_to("1.5") %}
{% if dbt_unit_testing.version_bigger_or_equal_to("1.5.0") %}
select * from {{ ref('model_with_version', v=1) }} where a > 1
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% if dbt_unit_testing.version_bigger_or_equal_to("1.5") %}
{% if dbt_unit_testing.version_bigger_or_equal_to("1.5.0") %}
select * from {{ ref('model_with_version', version=2) }} where a > 2
{% endif %}

2 changes: 1 addition & 1 deletion integration-tests/tests/unit/model_with_version.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
)
}}

{% call dbt_unit_testing.test('model_with_version', 'version1 ', version=1) %}
{% call dbt_unit_testing.test('model_with_version', 'version 1', version=1) %}
{% call dbt_unit_testing.expect() %}
select 1 as a
{% endcall %}
Expand Down
11 changes: 10 additions & 1 deletion macros/utils.sql
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,16 @@
{% do context.update({test_key: {}}) %}
{% endmacro %}

{% macro split_and_pad_and_join(s, pad) %}
{% set parts = s.split('.') %}
{% set parts_2 = [] %}
{% for p in parts %}
{% do parts_2.append(dbt_unit_testing.pad(parts[loop.index-1], pad, pad_right=true)) %}
{% endfor %}
{{ return (parts_2 | join('.')) }}
{% endmacro %}

{% macro version_bigger_or_equal_to(v) %}
{{ return (dbt_version >= v )}}
{{ return (dbt_unit_testing.split_and_pad_and_join(dbt_version, 5) >= dbt_unit_testing.split_and_pad_and_join(v, 5)) }}
{% endmacro %}

0 comments on commit c997099

Please sign in to comment.