chorus/tests/channel.rs

71 lines
1.8 KiB
Rust
Raw Normal View History

2023-05-27 22:12:15 +02:00
mod common;
2023-05-29 18:50:09 +02:00
use chorus::types::{self, Channel};
2023-05-27 22:12:15 +02:00
#[tokio::test]
async fn get_channel() {
let mut bundle = common::setup().await;
let bundle_channel = bundle.channel.clone();
let mut bundle_user = &mut bundle.user;
2023-05-27 22:12:15 +02:00
assert_eq!(
bundle_channel,
Channel::get(&mut bundle_user, &bundle_channel.id.to_string(),)
.await
.unwrap()
2023-05-27 22:12:15 +02:00
);
common::teardown(bundle).await
}
2023-05-28 23:04:56 +02:00
#[tokio::test]
async fn delete_channel() {
let mut bundle = common::setup().await;
let result = bundle
.channel
2023-05-29 18:29:08 +02:00
.clone()
2023-05-28 23:04:56 +02:00
.delete(
&bundle.user.token,
bundle.instance.urls.get_api(),
&mut bundle.user.limits,
&mut bundle.instance.limits,
)
.await;
assert!(result.is_none());
2023-05-29 18:29:08 +02:00
common::teardown(bundle).await
2023-05-28 23:04:56 +02:00
}
2023-05-29 18:50:09 +02:00
#[tokio::test]
async fn modify_channel() {
let mut bundle = common::setup().await;
let modify_data: types::ChannelModifySchema = types::ChannelModifySchema {
name: Some("beepboop".to_string()),
channel_type: None,
topic: None,
icon: None,
bitrate: None,
user_limit: None,
rate_limit_per_user: None,
position: None,
permission_overwrites: None,
parent_id: None,
nsfw: None,
rtc_region: None,
default_auto_archive_duration: None,
default_reaction_emoji: None,
flags: None,
default_thread_rate_limit_per_user: None,
video_quality_mode: None,
};
let result = Channel::modify(
modify_data,
&bundle.user.token,
bundle.instance.urls.get_api(),
&bundle.channel.id.to_string(),
&mut bundle.user.limits,
&mut bundle.instance.limits,
)
.await
.unwrap();
assert_eq!(result.name, Some("beepboop".to_string()));
common::teardown(bundle).await
}