Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix testing migration #102

Merged
merged 3 commits into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading