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

Feature request: flavor = "multi_thread" support for #[sqlx::test] #3510

Open
vikanezrimaya opened this issue Sep 18, 2024 · 1 comment
Open
Labels
enhancement New feature or request

Comments

@vikanezrimaya
Copy link

vikanezrimaya commented Sep 18, 2024

Is your feature request related to a problem? Please describe.
From documentation:

#[sqlx::test] does not recognize any of the control arguments supported by #[tokio::test] as that would have complicated the implementation. If your use case requires any of those, feel free to open an issue.

Thus this issue.

Describe the solution you'd like

#[sqlx::test(tokio_flavor = "multi_thread", tokio_threads = 1)]

Describe alternatives you've considered

  • Reimplementing #[sqlx::test] manually in my project without a macro
    • Tedious
  • A second macro that would spawn a multi-threaded runtime
  • Having #[sqlx::test] not spawn a runtime for non-async functions May not be feasible due to how the macro is structured
    • This would allow me to bring my own #[tokio::test] invocation, since the Tokio macros de-asyncifiy the functions they're used on.
  • Just spawn a multi-threaded runtime by default

Additional context
n/a

@vikanezrimaya vikanezrimaya added the enhancement New feature or request label Sep 18, 2024
@abonander
Copy link
Collaborator

I'd accept a PR to support this:

#[sqlx::test(tokio(...))]

and then we don't have to parse ..., we can just pass it directly to #[tokio::test(...)].

The problem is, that's not currently how it works internally (it expands to more than just #[tokio::test]), so we'd need to move some stuff around.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants