Change the name of "inner" function generated by #[sqlx::test]
#3072
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
This patch addresses an issue with the
#[sqlx::test]
attribute macro that causes problems when used in conjunction with the insta snapshot testing library.When using
sqlx::test
, the test code is wrapped inside an inner function, which can lead to snapshot files being generated with the name of the inner function (inner
), causing filename conflicts when multiple functions exist within the same module.mitsuhiko/insta#434
This PR modifies the
sqlx::test
macro to ensure that insta uses the correct function name (select_foo
in this case) when generating snapshot files, thereby avoiding filename conflicts and ensuring that snapshot tests work as expected.Changes
Modified the
sqlx::test
macro to generate the inner function with the original function name (select_foo
in this case) when generating the test function, ensuring that insta uses the correct function name when generating snapshot files.