Compare commits

..

No commits in common. "262a52a8e97ea36c4b51abaa668206b56f56ee85" and "3ffb124cd4a04c40c2fcb0bc08f6e05360dd0a2c" have entirely different histories.

8 changed files with 22 additions and 50 deletions

View File

@ -47,7 +47,6 @@ pub struct VoiceState {
}
impl Updateable for VoiceState {
#[cfg(not(tarpaulin_include))]
fn id(&self) -> Snowflake {
if let Some(id) = self.id {
id // ID exists: Only the case for Spacebar Server impls

View File

@ -31,9 +31,7 @@ pub struct AutoModerationRuleUpdate {
}
#[cfg(feature = "client")]
#[cfg(not(tarpaulin_include))]
impl UpdateMessage<AutoModerationRule> for AutoModerationRuleUpdate {
#[cfg(not(tarpaulin_include))]
fn id(&self) -> Option<Snowflake> {
Some(self.rule.id)
}

View File

@ -39,7 +39,6 @@ impl WebSocketEvent for ChannelCreate {}
#[cfg(feature = "client")]
impl UpdateMessage<Guild> for ChannelCreate {
#[cfg(not(tarpaulin_include))]
fn id(&self) -> Option<Snowflake> {
self.channel.guild_id
}
@ -74,8 +73,6 @@ impl UpdateMessage<Channel> for ChannelUpdate {
let mut write = object_to_update.write().unwrap();
*write = self.channel.clone();
}
#[cfg(not(tarpaulin_include))]
fn id(&self) -> Option<Snowflake> {
Some(self.channel.id)
}
@ -114,7 +111,6 @@ pub struct ChannelDelete {
#[cfg(feature = "client")]
impl UpdateMessage<Guild> for ChannelDelete {
#[cfg(not(tarpaulin_include))]
fn id(&self) -> Option<Snowflake> {
self.channel.guild_id
}

View File

@ -30,9 +30,7 @@ pub struct GuildCreate {
}
#[cfg(feature = "client")]
#[cfg(not(tarpaulin_include))]
impl UpdateMessage<Guild> for GuildCreate {
#[cfg(not(tarpaulin_include))]
fn id(&self) -> Option<Snowflake> {
match &self.d {
GuildCreateDataOption::UnavailableGuild(unavailable) => Some(unavailable.id),
@ -94,7 +92,6 @@ impl WebSocketEvent for GuildUpdate {}
#[cfg(feature = "client")]
impl UpdateMessage<Guild> for GuildUpdate {
#[cfg(not(tarpaulin_include))]
fn id(&self) -> Option<Snowflake> {
Some(self.guild.id)
}
@ -114,7 +111,6 @@ pub struct GuildDelete {
#[cfg(feature = "client")]
impl UpdateMessage<Guild> for GuildDelete {
#[cfg(not(tarpaulin_include))]
fn id(&self) -> Option<Snowflake> {
Some(self.guild.id)
}
@ -229,7 +225,6 @@ impl WebSocketEvent for GuildRoleCreate {}
#[cfg(feature = "client")]
impl UpdateMessage<Guild> for GuildRoleCreate {
#[cfg(not(tarpaulin_include))]
fn id(&self) -> Option<Snowflake> {
Some(self.guild_id)
}
@ -263,7 +258,6 @@ impl WebSocketEvent for GuildRoleUpdate {}
#[cfg(feature = "client")]
impl UpdateMessage<RoleObject> for GuildRoleUpdate {
#[cfg(not(tarpaulin_include))]
fn id(&self) -> Option<Snowflake> {
Some(self.role.id)
}

View File

@ -135,7 +135,6 @@ where
fn update(&mut self, object_to_update: Shared<T>) {
update_object(self.get_json(), object_to_update)
}
#[cfg(not(tarpaulin_include))]
fn id(&self) -> Option<Snowflake>;
}

View File

@ -32,7 +32,6 @@ impl WebSocketEvent for ThreadUpdate {}
#[cfg(feature = "client")]
impl UpdateMessage<Channel> for ThreadUpdate {
#[cfg(not(tarpaulin_include))]
fn id(&self) -> Option<Snowflake> {
Some(self.thread.id)
}

View File

@ -2,10 +2,7 @@ mod common;
use chorus::errors::GatewayError;
use chorus::gateway::*;
use chorus::types::{
self, Channel, ChannelCreateSchema, ChannelModifySchema, IntoShared, RoleCreateModifySchema,
RoleObject,
};
use chorus::types::{self, ChannelModifySchema, IntoShared, RoleCreateModifySchema, RoleObject};
#[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::*;
#[cfg(target_arch = "wasm32")]
@ -39,10 +36,7 @@ async fn test_gateway_authenticate() {
#[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() {
// PRETTYFYME: This test is a bit of a mess, but it works. Ideally, each self-updating struct
// would have its own test.
let mut bundle = common::setup().await;
let received_channel = bundle
.user
.gateway
@ -70,34 +64,6 @@ async fn test_self_updating_structs() {
"selfupdating".to_string()
);
let guild = bundle
.user
.gateway
.observe_and_into_inner(bundle.guild.clone())
.await;
assert!(guild.channels.is_none());
Channel::create(
&mut bundle.user,
guild.id,
None,
ChannelCreateSchema {
name: "selfupdating2".to_string(),
channel_type: Some(types::ChannelType::GuildText),
..Default::default()
},
)
.await
.unwrap();
let guild = bundle
.user
.gateway
.observe_and_into_inner(guild.into_shared())
.await;
assert!(guild.channels.is_some());
assert!(guild.channels.as_ref().unwrap().len() == 1);
common::teardown(bundle).await
}

View File

@ -1,7 +1,28 @@
use chorus::errors::ChorusError;
use chorus::ratelimiter::ChorusRequest;
mod common;
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
async fn hit_ratelimit() {
let mut bundle = common::setup().await;
let mut _count = 0;
let guild = bundle.guild.read().unwrap().clone();
while _count < 1000 {
_count += 1;
match guild.channels(&mut bundle.user).await {
Err(ChorusError::RateLimited { bucket: _ }) => {
return;
}
Err(_) => panic!("Hit different rate limit"),
_ => continue,
}
}
common::teardown(bundle).await;
panic!("Ratelimit never triggered");
}
#[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)]
#[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
async fn get_limit_config() {