fix: make postgres tests hygienic for persistent databases#6
Merged
Conversation
Each test now cleans up only the data it created instead of truncating the entire table. Tests use unique, prefixed names and clean up both before and after to handle interrupted prior runs. Store tests: - Removed DELETE FROM secrets in test_store() - Added cleanup() helper that deletes by specific names - list test uses contains() assertions instead of exact count - Unique names per test (pg-roundtrip, pg-list-a, etc.) Audit tests: - Removed DELETE FROM audit_events in test_audit_log() - Added cleanup_agent/cleanup_secret/cleanup_lease helpers - Unique agent names (test-alice, test-bob) to avoid collisions - Each test cleans before and after
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Postgres integration tests previously truncated the entire
secretsandaudit_eventstables in their setup, making them non-hygienic when run against a persistent local database. Tests would fail if run a second time without cleaning the DB, or if run concurrently.Changes
test_store()andtest_audit_log()no longer runDELETE FROM <table>.pg-roundtrip,pg-list-a,test-alice, etc.) to avoid collisions.list_returns_metadatausescontains()instead of exact count, since other data may exist in the table.Test plan
cargo clippy --manifest-path crates/zerolease-store-postgres/Cargo.toml --all-targets— cleancargo test --workspace— all pass