diff --git a/dev-requirements.txt b/dev-requirements.txt index c696a773c..2448b0903 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,6 +1,6 @@ # install latest changes in dbt-core # TODO: how to automate switching from develop to version branches? -git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-core&subdirectory=core +git+https://github.com/dbt-labs/dbt-core.git@paw%2Fmetadata-freshness#egg=dbt-core&subdirectory=core git+https://github.com/dbt-labs/dbt-core.git#egg=dbt-tests-adapter&subdirectory=tests/adapter # if version 1.x or greater -> pin to major version diff --git a/tests/functional/adapter/test_get_last_relation_modified.py b/tests/functional/adapter/test_get_last_relation_modified.py new file mode 100644 index 000000000..61270b38f --- /dev/null +++ b/tests/functional/adapter/test_get_last_relation_modified.py @@ -0,0 +1,33 @@ +import os +import pytest + +from dbt.tests.util import run_dbt + +freshness_via_metadata_schema_yml = """version: 2 +sources: + - name: test_source + freshness: + warn_after: {count: 10, period: hour} + error_after: {count: 1, period: day} + schema: "{{ env_var('DBT_TEST_SCHEMA_NAME_VARIABLE') }}" + tables: + - name: test_table +""" + + +class TestGetLastRelationModified: + @pytest.fixture(scope="class", autouse=True) + def set_env_vars(self, project): + os.environ["DBT_TEST_SCHEMA_NAME_VARIABLE"] = project.test_schema + 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): + project.run_sql( + f"create table {project.test_schema}.test_table (id integer autoincrement, name varchar(100) not null);" + ) + run_dbt(["source", "freshness"])