Refactor test

This commit is contained in:
bitfl0wer 2023-08-16 01:11:32 +02:00
parent 5f0f19e8ce
commit e43fe061b3
1 changed files with 14 additions and 19 deletions

View File

@ -29,35 +29,30 @@ async fn test_gateway_authenticate() {
#[tokio::test] #[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 channel_updater = bundle.user.gateway.observe(bundle.channel.clone()).await; let received_channel = bundle
let received_channel = channel_updater.borrow().clone().read().unwrap().clone(); .user
.gateway
.observe_and_into_inner(bundle.channel.clone())
.await;
assert_eq!(received_channel, bundle.channel.read().unwrap().clone()); assert_eq!(received_channel, bundle.channel.read().unwrap().clone());
let updater = bundle.user.gateway.observe(bundle.channel.clone()).await;
assert_eq!(
updater
.borrow()
.clone()
.read()
.unwrap()
.clone()
.name
.unwrap(),
bundle.channel.read().unwrap().clone().name.unwrap()
);
let channel = bundle.channel.read().unwrap().clone();
let modify_schema = ChannelModifySchema { let modify_schema = ChannelModifySchema {
name: Some("selfupdating".to_string()), name: Some("selfupdating".to_string()),
..Default::default() ..Default::default()
}; };
Channel::modify(&channel, modify_schema, &mut bundle.user) received_channel
.modify(modify_schema, &mut bundle.user)
.await .await
.unwrap(); .unwrap();
assert_eq!( assert_eq!(
updater.borrow().read().unwrap().clone().name.unwrap(), bundle
.user
.gateway
.observe_and_into_inner(bundle.channel.clone())
.await
.name
.unwrap(),
"selfupdating".to_string() "selfupdating".to_string()
); );