diff --git a/tests/adapter/dbt/tests/adapter/utils/fixture_get_powers_of_two.py b/tests/adapter/dbt/tests/adapter/utils/fixture_get_powers_of_two.py new file mode 100644 index 00000000000..ff464c5076e --- /dev/null +++ b/tests/adapter/dbt/tests/adapter/utils/fixture_get_powers_of_two.py @@ -0,0 +1,39 @@ +# dateadd + +seeds__data_get_powers_of_two_csv = """upper_bound,result +1,1 +4,2 +27,5 +256,8 +3125,12 +46656,16 +823543,20 +16777216,24 +387420489,29 +""" + + +models__test_get_powers_of_two_sql = """ +with data as ( + select + cast({{ 'upper_bound' }} as {{ type_int() }}) as upper_bound, + cast({{ 'result' }} as {{ type_int() }}) as result + from {{ ref('data_get_powers_of_two') }} + +) + +select + {{get_powers_of_two('upper_bound')}} as actual, + result as expected +from data +""" + +models__test_get_powers_of_two_yml = """ +version: 2 +models: + - name: test_powers_of_two + tests: + - assert_equal: + actual: actual + expected: expected +""" diff --git a/tests/adapter/dbt/tests/adapter/utils/test_get_powers_of_two.py b/tests/adapter/dbt/tests/adapter/utils/test_get_powers_of_two.py new file mode 100644 index 00000000000..9ad47957315 --- /dev/null +++ b/tests/adapter/dbt/tests/adapter/utils/test_get_powers_of_two.py @@ -0,0 +1,26 @@ +import pytest +from dbt.tests.adapter.utils.base_utils import BaseUtils +from dbt.tests.adapter.utils.fixture_get_powers_of_two import ( + seeds__data_get_powers_of_two_csv, + models__test_get_powers_of_two_sql, + models__test_get_powers_of_two_yml, +) + + +class BaseGetPowersOfTwo(BaseUtils): + @pytest.fixture(scope="class") + def seeds(self): + return {"data_get_powers_of_two.csv": seeds__data_get_powers_of_two_csv} + + @pytest.fixture(scope="class") + def models(self): + return { + "test_get_powers_of_two.yml": models__test_get_powers_of_two_yml, + "test_get_powers_of_two.sql": self.interpolate_macro_namespace( + models__test_get_powers_of_two_sql, "get_powers_of_two" + ), + } + + +class TestGetPowersOfTwo(BaseGetPowersOfTwo): + pass