From 38c95255c58579fbf5584458ad56211b7c76f2fb Mon Sep 17 00:00:00 2001 From: bitfl0wer Date: Wed, 22 Nov 2023 14:39:32 +0100 Subject: [PATCH] Replace #[tokio::test] w/ wasm-ok macro calls --- tests/auth.rs | 3 ++- tests/channels.rs | 15 ++++++++++----- tests/gateway.rs | 12 ++++++++---- tests/guilds.rs | 15 ++++++++++----- tests/instance.rs | 3 ++- tests/invites.rs | 3 ++- tests/members.rs | 3 ++- tests/messages.rs | 12 ++++++++---- tests/relationships.rs | 12 ++++++++---- tests/roles.rs | 6 ++++-- 10 files changed, 56 insertions(+), 28 deletions(-) diff --git a/tests/auth.rs b/tests/auth.rs index f73a01f..086c8ba 100644 --- a/tests/auth.rs +++ b/tests/auth.rs @@ -7,7 +7,8 @@ wasm_bindgen_test_configure!(run_in_browser); mod common; -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn test_registration() { let bundle = common::setup().await; let reg = RegisterSchema { diff --git a/tests/channels.rs b/tests/channels.rs index d489d94..864165a 100644 --- a/tests/channels.rs +++ b/tests/channels.rs @@ -11,7 +11,8 @@ use wasm_bindgen_test::*; #[cfg(target_arch = "wasm32")] wasm_bindgen_test_configure!(run_in_browser); -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn get_channel() { let mut bundle = common::setup().await; let bundle_channel = bundle.channel.read().unwrap().clone(); @@ -24,7 +25,8 @@ async fn get_channel() { common::teardown(bundle).await } -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn delete_channel() { let mut bundle = common::setup().await; let channel_guard = bundle.channel.write().unwrap().clone(); @@ -33,7 +35,8 @@ async fn delete_channel() { common::teardown(bundle).await } -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn modify_channel() { const CHANNEL_NAME: &str = "beepboop"; let mut bundle = common::setup().await; @@ -91,7 +94,8 @@ async fn modify_channel() { common::teardown(bundle).await } -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn get_channel_messages() { let mut bundle = common::setup().await; let channel_id: Snowflake = bundle.channel.read().unwrap().id; @@ -147,7 +151,8 @@ async fn get_channel_messages() { common::teardown(bundle).await } -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn create_dm() { let mut bundle = common::setup().await; let other_user = bundle.create_user("integrationtestuser2").await; diff --git a/tests/gateway.rs b/tests/gateway.rs index 2cbbe90..b564cde 100644 --- a/tests/gateway.rs +++ b/tests/gateway.rs @@ -10,7 +10,8 @@ use wasm_bindgen_test::*; #[cfg(target_arch = "wasm32")] wasm_bindgen_test_configure!(run_in_browser); -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] /// Tests establishing a connection (hello and heartbeats) on the local gateway; async fn test_gateway_establish() { let bundle = common::setup().await; @@ -19,7 +20,8 @@ async fn test_gateway_establish() { common::teardown(bundle).await } -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] /// Tests establishing a connection and authenticating async fn test_gateway_authenticate() { let bundle = common::setup().await; @@ -33,7 +35,8 @@ async fn test_gateway_authenticate() { common::teardown(bundle).await } -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn test_self_updating_structs() { let mut bundle = common::setup().await; let received_channel = bundle @@ -66,7 +69,8 @@ async fn test_self_updating_structs() { common::teardown(bundle).await } -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn test_recursive_self_updating_structs() { // Setup let mut bundle = common::setup().await; diff --git a/tests/guilds.rs b/tests/guilds.rs index 78d10c9..360113d 100644 --- a/tests/guilds.rs +++ b/tests/guilds.rs @@ -9,7 +9,8 @@ use wasm_bindgen_test::*; #[cfg(target_arch = "wasm32")] wasm_bindgen_test_configure!(run_in_browser); -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn guild_creation_deletion() { let mut bundle = common::setup().await; @@ -31,7 +32,8 @@ async fn guild_creation_deletion() { common::teardown(bundle).await } -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn get_channels() { let mut bundle = common::setup().await; let guild = bundle.guild.read().unwrap().clone(); @@ -39,7 +41,8 @@ async fn get_channels() { common::teardown(bundle).await; } -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn guild_create_ban() { // TODO: When routes exist to check if user x is on guild y, add this as an assertion to check // if Spacebar actually bans the user. @@ -76,7 +79,8 @@ async fn guild_create_ban() { common::teardown(bundle).await } -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn modify_guild() { let mut bundle = common::setup().await; let schema = GuildModifySchema { @@ -91,7 +95,8 @@ async fn modify_guild() { common::teardown(bundle).await } -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn guild_remove_member() { let mut bundle = common::setup().await; let channel = bundle.channel.read().unwrap().clone(); diff --git a/tests/instance.rs b/tests/instance.rs index d7a2caa..56f4d6d 100644 --- a/tests/instance.rs +++ b/tests/instance.rs @@ -5,7 +5,8 @@ use wasm_bindgen_test::*; #[cfg(target_arch = "wasm32")] wasm_bindgen_test_configure!(run_in_browser); -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn generate_general_configuration_schema() { let bundle = common::setup().await; bundle diff --git a/tests/invites.rs b/tests/invites.rs index 472b87a..d830ee8 100644 --- a/tests/invites.rs +++ b/tests/invites.rs @@ -6,7 +6,8 @@ use wasm_bindgen_test::*; #[cfg(target_arch = "wasm32")] wasm_bindgen_test_configure!(run_in_browser); -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn create_accept_invite() { let mut bundle = common::setup().await; let channel = bundle.channel.read().unwrap().clone(); diff --git a/tests/members.rs b/tests/members.rs index c95e6fc..c9072ef 100644 --- a/tests/members.rs +++ b/tests/members.rs @@ -7,7 +7,8 @@ wasm_bindgen_test_configure!(run_in_browser); mod common; -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn add_remove_role() -> ChorusResult<()> { let mut bundle = common::setup().await; let guild = bundle.guild.read().unwrap().id; diff --git a/tests/messages.rs b/tests/messages.rs index a06a615..8228aa7 100644 --- a/tests/messages.rs +++ b/tests/messages.rs @@ -10,7 +10,8 @@ wasm_bindgen_test_configure!(run_in_browser); mod common; -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn send_message() { let mut bundle = common::setup().await; let message = types::MessageSendSchema { @@ -22,7 +23,8 @@ async fn send_message() { common::teardown(bundle).await } -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn send_message_attachment() { let f = File::open("./README.md").unwrap(); let mut reader = BufReader::new(f); @@ -59,7 +61,8 @@ async fn send_message_attachment() { common::teardown(bundle).await } -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn search_messages() { let f = File::open("./README.md").unwrap(); let mut reader = BufReader::new(f); @@ -105,7 +108,8 @@ async fn search_messages() { assert_eq!(query_result.get(0).unwrap().id, message.id); } -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn test_stickies() { let mut bundle = common::setup().await; let message = types::MessageSendSchema { diff --git a/tests/relationships.rs b/tests/relationships.rs index d013223..156f6eb 100644 --- a/tests/relationships.rs +++ b/tests/relationships.rs @@ -7,7 +7,8 @@ wasm_bindgen_test_configure!(run_in_browser); mod common; -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn test_get_mutual_relationships() { let mut bundle = common::setup().await; let mut other_user = bundle.create_user("integrationtestuser2").await; @@ -28,7 +29,8 @@ async fn test_get_mutual_relationships() { common::teardown(bundle).await } -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn test_get_relationships() { let mut bundle = common::setup().await; let mut other_user = bundle.create_user("integrationtestuser2").await; @@ -51,7 +53,8 @@ async fn test_get_relationships() { common::teardown(bundle).await } -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn test_modify_relationship_friends() { let mut bundle = common::setup().await; let mut other_user = bundle.create_user("integrationtestuser2").await; @@ -102,7 +105,8 @@ async fn test_modify_relationship_friends() { common::teardown(bundle).await } -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn test_modify_relationship_block() { let mut bundle = common::setup().await; let mut other_user = bundle.create_user("integrationtestuser2").await; diff --git a/tests/roles.rs b/tests/roles.rs index 547db47..ca58582 100644 --- a/tests/roles.rs +++ b/tests/roles.rs @@ -7,7 +7,8 @@ wasm_bindgen_test_configure!(run_in_browser); mod common; -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn create_and_get_roles() { let mut bundle = common::setup().await; let permissions = types::PermissionFlags::CONNECT | types::PermissionFlags::MANAGE_EVENTS; @@ -36,7 +37,8 @@ async fn create_and_get_roles() { common::teardown(bundle).await } -#[tokio::test] +#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] +#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] async fn get_and_delete_role() { let mut bundle = common::setup().await; let guild_id = bundle.guild.read().unwrap().id;