Skip to content

Commit

Permalink
Fix testing migration (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikealfare authored Feb 22, 2024
1 parent b31d6b8 commit fef956f
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 43 deletions.
4 changes: 3 additions & 1 deletion dbt/tests/adapter/column_types/test_column_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ def run_and_test(self):
results = run_dbt(["test"])
assert len(results) == 1


class BasePostgresColumnTypes(BaseColumnTypes):
@pytest.fixture(scope="class")
def models(self):
return {"model.sql": fixtures.model_sql, "schema.yml": fixtures.schema_yml}
Expand All @@ -23,5 +25,5 @@ def test_run_and_test(self, project):
self.run_and_test()


class TestPostgresColumnTypes(BaseColumnTypes):
class TestPostgresColumnTypes(BasePostgresColumnTypes):
pass
16 changes: 16 additions & 0 deletions dbt/tests/adapter/hooks/data/seed_model.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
drop table if exists {schema}.on_model_hook;

create table {schema}.on_model_hook (
test_state TEXT, -- start|end
target_dbname TEXT,
target_host TEXT,
target_name TEXT,
target_schema TEXT,
target_type TEXT,
target_user TEXT,
target_pass TEXT,
target_threads INTEGER,
run_started_at TEXT,
invocation_id TEXT,
thread_id TEXT
);
16 changes: 16 additions & 0 deletions dbt/tests/adapter/hooks/data/seed_run.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
drop table if exists {schema}.on_run_hook;

create table {schema}.on_run_hook (
test_state TEXT, -- start|end
target_dbname TEXT,
target_host TEXT,
target_name TEXT,
target_schema TEXT,
target_type TEXT,
target_user TEXT,
target_pass TEXT,
target_threads INTEGER,
run_started_at TEXT,
invocation_id TEXT,
thread_id TEXT
);
40 changes: 0 additions & 40 deletions dbt/tests/adapter/hooks/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,43 +360,3 @@
4,5,6
7,8,9
"""


tables__on_model_hook = """
drop table if exists {schema}.on_model_hook;
create table {schema}.on_model_hook (
test_state TEXT, -- start|end
target_dbname TEXT,
target_host TEXT,
target_name TEXT,
target_schema TEXT,
target_type TEXT,
target_user TEXT,
target_pass TEXT,
target_threads INTEGER,
run_started_at TEXT,
invocation_id TEXT,
thread_id TEXT
);
"""


tables__on_run_hook = """
drop table if exists {schema}.on_run_hook;
create table {schema}.on_run_hook (
test_state TEXT, -- start|end
target_dbname TEXT,
target_host TEXT,
target_name TEXT,
target_schema TEXT,
target_type TEXT,
target_user TEXT,
target_pass TEXT,
target_threads INTEGER,
run_started_at TEXT,
invocation_id TEXT,
thread_id TEXT
);
"""
2 changes: 1 addition & 1 deletion dbt/tests/adapter/hooks/test_model_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
class BaseTestPrePost:
@pytest.fixture(scope="class", autouse=True)
def setUp(self, project):
project.run_sql(fixtures.tables__on_model_hook)
project.run_sql_file(project.test_data_dir / Path("seed_model.sql"))

def get_ctx_vars(self, state, count, project):
fields = [
Expand Down
3 changes: 2 additions & 1 deletion dbt/tests/adapter/hooks/test_run_hooks.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from pathlib import Path

import pytest

Expand All @@ -9,7 +10,7 @@
class BasePrePostRunHooks:
@pytest.fixture(scope="function")
def setUp(self, project):
project.run_sql(fixtures.tables__on_run_hook)
project.run_sql_file(project.test_data_dir / Path("seed_run.sql"))
project.run_sql(f"drop table if exists { project.test_schema }.schemas")
project.run_sql(f"drop table if exists { project.test_schema }.db_schemas")
os.environ["TERM_TEST"] = "TESTING"
Expand Down

0 comments on commit fef956f

Please sign in to comment.