Skip to main content

Snapshot / Golden File Update Process

Overview

Golden (snapshot) files store expected test outputs. When behaviour intentionally changes, golden files must be updated and the change must be reviewed so snapshots do not drift silently.

Where Golden Files Live

  • Task 1 (ETL): tasks/data_ingestion_transformation/tests/golden/ — e.g. a1_expected.json, a2_expected.json for key scenarios. Used by tests/test_golden.py.
  • Task 3 (SQL): tasks/sql/tests/expected_output.csvsingle source of truth for the balance query expected result. Used by test_balance_query.py.

How to Update Golden Files

  1. Run the test so it fails with a clear diff (e.g. assertion or comparison error).
  2. Update the golden file manually:
    • Task 1: Edit the relevant tests/golden/<scenario>_expected.json (e.g. adjust expected_silver_rows, partitions).
    • Task 3: Edit tasks/sql/tests/expected_output.csv to match the new expected query output.
  3. Re-run the test and confirm it passes.
  4. Commit the change in a dedicated commit or PR so reviewers can see exactly what changed.

There is no pytest --snapshot-update flag in this project; updates are manual. If you introduce a snapshot library (e.g. syrupy, pytest-snapshot), document its update command here.

Review Policy

  • All changes to golden files must go through PR review. Reviewers should confirm that the new expected output is correct and that the change is intentional (e.g. business rule change, schema change), not a mistaken regression.

References

  • TEST_RESULTS_OVERVIEW
  • Task 3: README_TESTING (source only) — expected_output.csv is the single source of truth for SQL query output.
© 2026 Stephen AdeiCC BY 4.0