Skip to content

Commit

Permalink
Add tests for YAML-defined snapshots.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterallenwebb committed Sep 20, 2024
1 parent 5c0d7ce commit 5743edc
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/functional/snapshots/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,20 @@
{% endsnapshot %}
"""

snapshots_pg__snapshot_yml = """
version: 2
snapshots:
- name: snapshot_actual
relation: "ref('seed')"
config:
unique_key: "id || '-' || first_name"
strategy: timestamp
updated_at: updated_at
meta:
owner: 'a_owner'
"""

snapshots_pg__snapshot_no_target_schema_sql = """
{% snapshot snapshot_actual %}
Expand Down
22 changes: 22 additions & 0 deletions tests/functional/snapshots/test_basic_snapshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
seeds__seed_newcol_csv,
snapshots_pg__snapshot_no_target_schema_sql,
snapshots_pg__snapshot_sql,
snapshots_pg__snapshot_yml,
snapshots_pg_custom__snapshot_sql,
snapshots_pg_custom_namespaced__snapshot_sql,
)
Expand Down Expand Up @@ -372,3 +373,24 @@ def test_updated_at_snapshot(self, project):
class TestRefUpdatedAtCheckCols(UpdatedAtCheckCols):
def test_updated_at_ref(self, project):
ref_setup(project, num_snapshot_models=2)


class BasicYaml(Basic):
@pytest.fixture(scope="class")
def snapshots(self):
"""Overrides the same function in Basic to use the YAML method of
defining a snapshot."""
return {"snapshot.yml": snapshots_pg__snapshot_yml}

@pytest.fixture(scope="class")
def models(self):
"""Overrides the same function in Basic to use a modified version of
schema.yml without snapshot config."""
return {
"ref_snapshot.sql": models__ref_snapshot_sql,
}


class TestBasicSnapshotYaml(BasicYaml):
def test_basic_snapshot_yaml(self, project):
snapshot_setup(project, num_snapshot_models=1)
Empty file.

0 comments on commit 5743edc

Please sign in to comment.