Test RoleObject::create() and ::get_all()

This commit is contained in:
bitfl0wer 2023-06-09 12:03:56 +02:00
parent fc66036674
commit f44e1f5856
No known key found for this signature in database
GPG Key ID: 84BBB60DF895ABF2
1 changed files with 32 additions and 1 deletions

View File

@ -1,3 +1,34 @@
mod common; mod common;
use chorus::types; use chorus::types::{self, RoleCreateModifySchema};
#[tokio::test]
async fn create_and_get_roles() {
let mut bundle = common::setup().await;
let role_create_schema: types::RoleCreateModifySchema = RoleCreateModifySchema {
name: Some("cool person".to_string()),
permissions: Some("2251804225".to_string()),
hoist: Some(true),
icon: None,
unicode_emoji: Some("".to_string()),
mentionable: Some(true),
position: None,
color: None,
};
let guild_id = bundle.guild.id.clone().to_string();
let role = types::RoleObject::create(&mut bundle.user, &guild_id, role_create_schema)
.await
.unwrap();
let expected = types::RoleObject::get_all(&mut bundle.user, &guild_id)
.await
.unwrap()
.unwrap()
.iter()
.nth(1)
.unwrap()
.clone();
assert_eq!(role, expected);
common::teardown(bundle).await
}