From 6886039324cb8f86864d3578637dfe9e7e97bd4c Mon Sep 17 00:00:00 2001 From: Noritaka Sekiyama Date: Tue, 14 Nov 2023 15:10:49 +0900 Subject: [PATCH] Added TestSnapshotTimestampGlue --- tests/functional/adapter/test_snapshot.py | 44 ++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/tests/functional/adapter/test_snapshot.py b/tests/functional/adapter/test_snapshot.py index 8abcff64..e4601a75 100644 --- a/tests/functional/adapter/test_snapshot.py +++ b/tests/functional/adapter/test_snapshot.py @@ -7,7 +7,7 @@ s3bucket = get_s3_location() region = get_region() -schema_name = "dbt_functional_test_snapshot01" +schema_name = "dbt_functional_test_01" def check_relation_rows(project, snapshot_name, count): @@ -83,4 +83,46 @@ class TestSnapshotTimestampGlue(BaseSnapshotTimestamp): def unique_schema(request, prefix) -> str: return schema_name + @pytest.fixture(scope='class', autouse=True) + def cleanup(self): + cleanup_s3_location(s3bucket + schema_name, region) + yield + + @pytest.fixture(scope="class") + def project_config_update(self): + return { + "seeds": { + "+file_format": "delta", + "quote_columns": False, + }, + "snapshots": { + "+file_format": "delta", + "+updated_at": "current_timestamp()", + "quote_columns": False, + }, + "quoting": { + "database": False, + "schema": False, + "identifier": False + }, + } + + def test_snapshot_timestamp(self, project): + # seed command + results = run_dbt(["seed"]) + assert len(results) == 3 + + # snapshot command + results = run_dbt(["snapshot"]) + assert len(results) == 1 + + # snapshot has 10 rows + check_relation_rows(project, "ts_snapshot", 10) + + # point at the "added" seed so the snapshot sees 10 new rows + results = run_dbt(["snapshot", "--vars", "seed_name: added"]) + + # snapshot now has 20 rows + check_relation_rows(project, "ts_snapshot", 20) + pass