Skip to content

Commit

Permalink
Assert that incremental strategy validation raises correct error message
Browse files Browse the repository at this point in the history
  • Loading branch information
QMalcolm committed Oct 17, 2024
1 parent 2a1fef1 commit 96e7854
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions dbt-tests-adapter/dbt/tests/adapter/basic/test_incremental.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,34 @@ def project_config_update(self):
def models(self):
return {
"incremental.sql": files.incremental_invalid_strategy_sql,
"schema.yml": files.schema_base_yml,
}

@pytest.fixture(scope="class")
def seeds(self):
return {"base.csv": files.seeds_base_csv, "added.csv": files.seeds_added_csv}

@pytest.fixture(autouse=True)
def clean_up(self, project):
yield
with project.adapter.connection_named("__test"):
relation = project.adapter.Relation.create(
database=project.database, schema=project.test_schema
)
project.adapter.drop_schema(relation)

def test_incremental_invalid_strategy(self, project):
# seed command
results = run_dbt(["seed"])
assert len(results) == 2

# try to run the incremental model, it should fail on the first attempt
results = run_dbt(["run"], expect_pass=False)
assert len(results.results) == 1
assert (
'dbt could not find an incremental strategy macro with the name "get_incremental_bad_strategy_sql"'
in results.results[0].message
)


class Testincremental(BaseIncremental):
Expand All @@ -116,7 +131,3 @@ class Testincremental(BaseIncremental):

class TestBaseIncrementalNotSchemaChange(BaseIncrementalNotSchemaChange):
pass


class TestBaseIncrementalBadStrategy(BaseIncrementalBadStrategy):
pass

0 comments on commit 96e7854

Please sign in to comment.