Skip to content

Commit

Permalink
migrate 034 integration test to functional (#6054)
Browse files Browse the repository at this point in the history
* migrate 034 integration test to functional

* formatting fixes

* move to adapter directory

* add extra args
  • Loading branch information
colin-rogers-dbt authored Oct 12, 2022
1 parent 6de1d29 commit 0959979
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 53 deletions.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@


from typing import List, Optional
import pytest

from dbt.tests.util import run_dbt


_DEFAULT_CHANGE_RELATION_TYPE_MODEL = """
{{ config(materialized=var('materialized')) }}
select '{{ var("materialized") }}' as materialization
{% if var('materialized') == 'incremental' and is_incremental() %}
where 'abc' != (select max(materialization) from {{ this }})
{% endif %}
"""


class BaseChangeRelationTypeValidator:
@pytest.fixture(scope="class")
def models(self):
return {
"model_mc_modelface.sql": _DEFAULT_CHANGE_RELATION_TYPE_MODEL
}

def _run_and_check_materialization(self, materialization, extra_args: Optional[List] = None):
run_args = ["run", '--vars', f'materialized: {materialization}']
if extra_args:
run_args.extend(extra_args)
results = run_dbt(run_args)
assert results[0].node.config.materialized == materialization
assert len(results) == 1

def test_changing_materialization_changes_relation_type(self, project):
self._run_and_check_materialization('view')
self._run_and_check_materialization('table')
self._run_and_check_materialization('view')
self._run_and_check_materialization('incremental')
self._run_and_check_materialization('table', extra_args=['--full-refresh'])


class TestChangeRelationTypes(BaseChangeRelationTypeValidator):
pass

0 comments on commit 0959979

Please sign in to comment.