extend self updating structs test

This commit is contained in:
bitfl0wer 2024-01-24 23:01:38 +01:00
parent e073ff26c4
commit c950288df1
No known key found for this signature in database
GPG Key ID: 0ACD574FCF5226CF
1 changed files with 33 additions and 1 deletions

View File

@ -2,7 +2,10 @@ mod common;
use chorus::errors::GatewayError; use chorus::errors::GatewayError;
use chorus::gateway::*; use chorus::gateway::*;
use chorus::types::{self, ChannelModifySchema, IntoShared, RoleCreateModifySchema, RoleObject}; use chorus::types::{
self, Channel, ChannelCreateSchema, ChannelModifySchema, IntoShared, RoleCreateModifySchema,
RoleObject,
};
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
use wasm_bindgen_test::*; use wasm_bindgen_test::*;
#[cfg(target_arch = "wasm32")] #[cfg(target_arch = "wasm32")]
@ -37,6 +40,7 @@ async fn test_gateway_authenticate() {
#[cfg_attr(not(target_arch = "wasm32"), tokio::test)] #[cfg_attr(not(target_arch = "wasm32"), tokio::test)]
async fn test_self_updating_structs() { async fn test_self_updating_structs() {
let mut bundle = common::setup().await; let mut bundle = common::setup().await;
let received_channel = bundle let received_channel = bundle
.user .user
.gateway .gateway
@ -64,6 +68,34 @@ async fn test_self_updating_structs() {
"selfupdating".to_string() "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 common::teardown(bundle).await
} }