Skip to content

Commit

Permalink
Use shared test runtime
Browse files Browse the repository at this point in the history
  • Loading branch information
AntoniosBarotsis committed Dec 10, 2024
1 parent 4369c33 commit 31a4e27
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 11 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,4 @@ tokio = { version = "1.37.0", features = ["macros", "test-util", "rt-multi-threa
axum = "0.7.9"
svix = "1.42.0"
http-body-util = "0.1.2"
tokio-shared-rt = "0.1.0"
2 changes: 1 addition & 1 deletion src/api_keys.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ mod test {
use crate::types::CreateApiKeyOptions;
use crate::Result;

#[tokio::test]
#[tokio_shared_rt::test(shared = true)]
#[cfg(not(feature = "blocking"))]
async fn all() -> Result<()> {
let resend = &*CLIENT;
Expand Down
2 changes: 1 addition & 1 deletion src/audiences.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ mod test {
use crate::tests::CLIENT;
use crate::Result;

#[tokio::test]
#[tokio_shared_rt::test(shared = true)]
#[cfg(not(feature = "blocking"))]
async fn all() -> Result<()> {
let resend = &*CLIENT;
Expand Down
4 changes: 2 additions & 2 deletions src/broadcasts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ mod test {
Result,
};

#[tokio::test]
#[tokio_shared_rt::test(shared = true)]
#[cfg(not(feature = "blocking"))]
async fn create_send_broadcast() -> Result<()> {
let resend = &*CLIENT;
Expand Down Expand Up @@ -298,7 +298,7 @@ mod test {
Ok(())
}

#[tokio::test]
#[tokio_shared_rt::test(shared = true)]
#[cfg(not(feature = "blocking"))]
async fn list_get_broadcast() -> Result<()> {
let resend = &*CLIENT;
Expand Down
3 changes: 2 additions & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ impl Resend {
///
/// [`Resend`]: https://resend.com
pub fn new(api_key: &str) -> Self {
Self::with_client(api_key, ReqwestClient::default())
Self::with_client(api_key, ReqwestClient::builder().pool_max_idle_per_host(0).build().unwrap())
// Self::with_client(api_key, ReqwestClient::default())
}

/// Creates a new [`Resend`] client with a provided [`reqwest::Client`].
Expand Down
2 changes: 1 addition & 1 deletion src/contacts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ mod test {
use crate::types::{ContactChanges, ContactData};
use crate::Result;

#[tokio::test]
#[tokio_shared_rt::test(shared = true)]
#[cfg(not(feature = "blocking"))]
async fn all() -> Result<()> {
let resend = &*CLIENT;
Expand Down
2 changes: 1 addition & 1 deletion src/domains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ mod test {
Result,
};

#[tokio::test]
#[tokio_shared_rt::test(shared = true)]
#[cfg(not(feature = "blocking"))]
async fn all() -> Result<()> {
let resend = &*CLIENT;
Expand Down
4 changes: 2 additions & 2 deletions src/emails.rs
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ mod test {
use crate::{tests::CLIENT, Result};
use jiff::{Span, Timestamp, ToSpan, Zoned};

#[tokio::test]
#[tokio_shared_rt::test(shared = true)]
#[cfg(not(feature = "blocking"))]
async fn all() -> Result<()> {
let from = "Acme <[email protected]>";
Expand Down Expand Up @@ -582,7 +582,7 @@ mod test {
Ok(())
}

#[tokio::test]
#[tokio_shared_rt::test(shared = true)]
#[cfg(not(feature = "blocking"))]
async fn schedule_email() -> Result<()> {
let now_plus_1h = Zoned::now()
Expand Down
4 changes: 2 additions & 2 deletions src/rate_limit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ mod tests {
use super::{send_with_retry_opts, RetryOptions};
use crate::Error;

#[tokio::test]
#[tokio_shared_rt::test(shared = true)]
#[cfg(not(feature = "blocking"))]
async fn test_retry_count_err() {
let mut run_count = 0u32;
Expand Down Expand Up @@ -242,7 +242,7 @@ mod tests {
assert!(run_count == 0);
}

#[tokio::test]
#[tokio_shared_rt::test(shared = true)]
#[cfg(not(feature = "blocking"))]
async fn test_retry_count_ok() {
let mut retry_count = 0u32;
Expand Down

0 comments on commit 31a4e27

Please sign in to comment.