chorus/tests/member.rs

39 lines
1.1 KiB
Rust
Raw Normal View History

2023-06-10 00:39:04 +02:00
mod common;
#[tokio::test]
async fn add_remove_role() {
let mut bundle = common::setup().await;
let guild_id = &bundle.guild.id.to_string();
let role_id = &bundle.role.id.to_string();
let user_id = &bundle.user.object.id.to_string();
chorus::types::GuildMember::add_role(&mut bundle.user, guild_id, user_id, role_id).await;
2023-06-11 13:54:08 +02:00
let member = chorus::types::GuildMember::get(&mut bundle.user, guild_id, user_id)
2023-06-10 17:35:09 +02:00
.await
.unwrap();
let mut role_found = false;
for role in member.roles.iter() {
if role == role_id {
println!("Role found: {:?}", role);
role_found = true;
}
}
if !role_found {
assert!(false)
}
2023-06-10 00:39:04 +02:00
chorus::types::GuildMember::remove_role(&mut bundle.user, guild_id, user_id, role_id).await;
2023-06-11 13:54:08 +02:00
let member = chorus::types::GuildMember::get(&mut bundle.user, guild_id, user_id)
2023-06-10 17:35:09 +02:00
.await
.unwrap();
for role in member.roles.iter() {
if role != role_id {
role_found = false;
} else {
assert!(false);
}
}
if role_found {
assert!(false)
}
2023-06-10 00:39:04 +02:00
common::teardown(bundle).await
}