Skip to content

Commit

Permalink
test using custom schema for test
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-rogers-dbt committed Oct 11, 2023
1 parent ffedcc3 commit 4d8647e
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions tests/functional/adapter/test_get_last_relation_modified.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,33 @@
class TestGetLastRelationModified:
@pytest.fixture(scope="class", autouse=True)
def set_env_vars(self, project):
os.environ["DBT_TEST_SCHEMA_NAME_VARIABLE"] = project.test_schema
os.environ["DBT_TEST_SCHEMA_NAME_VARIABLE"] = (
project.test_schema + "_get_last_relation_modified"
)
yield
del os.environ["DBT_TEST_SCHEMA_NAME_VARIABLE"]

@pytest.fixture(scope="class")
def models(self):
return {"schema.yml": freshness_via_metadata_schema_yml}

def test_get_last_relation_modified(self, project, set_env_vars):
@pytest.fixture(scope="class")
def custom_schema(self, project, set_env_vars):
with project.adapter.connection_named("__test"):
relation = project.adapter.Relation.create(
database=project.database, schema=os.environ["DBT_TEST_SCHEMA_NAME_VARIABLE"]
)
project.adapter.drop_schema(relation)
project.adapter.create_schema(relation)

yield relation.schema

with project.adapter.connection_named("__test"):
project.adapter.drop_schema(relation)

def test_get_last_relation_modified(self, project, set_env_vars, custom_schema):
project.run_sql(
f"create table {project.test_schema}.test_table (id integer autoincrement, name varchar(100) not null);"
f"create table {os.environ['DBT_TEST_SCHEMA_NAME_VARIABLE']}.test_table (id integer autoincrement, name varchar(100) not null);"
)

warning_or_error = False
Expand Down

0 comments on commit 4d8647e

Please sign in to comment.