Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(dal): simplify tests that get schema/variants by name #5536

Merged
merged 1 commit into from
Feb 25, 2025

Conversation

jkeiser
Copy link
Contributor

@jkeiser jkeiser commented Feb 21, 2025

Separating this PR for a few ergonomics changes for tests:

  • Make Schema::find_by_name() error if schema is not found since all callers return an error themselves. This eliminates an unnecessary .expect() (Also rename to get_by_name())
  • Add SchemaVariant::default_by_schema_name() since that is a primary use case in tests (we almost never need the schema itself). Did not change all tests to use, just regenerate.rs for now since it's not a purely search-and-replace)
  • Use color_eyre errors in regenerate.rs to ergonomicize the tests (so we don't expect() all the time). Not doing this globally across all tests as it changes too many lines at once and isn't quite seach-and-replaceable

regenerate.rs tests are reduced by 15-20% with no changes; have very few expect()s breaking the flow; and many statements reduce to a single line now that the expect is gone.

Risk Mitigation

  • No behavior change.
  • Only one change outside of tests: si-fs no longer has its own bespoke error when the schema is not found by name. The error message still lists the name of the schema not found.
  • All tests still pass.

Copy link

github-actions bot commented Feb 21, 2025

Dependency Review

✅ No vulnerabilities or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

@github-actions github-actions bot added A-sdf Area: Primary backend API service [Rust] A-dal A-dal-test labels Feb 21, 2025
zacharyhamm
zacharyhamm previously approved these changes Feb 25, 2025
Copy link
Contributor

@zacharyhamm zacharyhamm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see how this change to find by name simplifies things. Surprised my use was the only one outside of tests... Looks good

SchemaVariant::default_id_for_schema_name()
@zacharyhamm zacharyhamm added this pull request to the merge queue Feb 25, 2025
Merged via the queue into main with commit 0a06dca Feb 25, 2025
9 checks passed
@zacharyhamm zacharyhamm deleted the jkeiser/test-ergo-1 branch February 25, 2025 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dal A-dal-test A-sdf Area: Primary backend API service [Rust]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants