move integration test from guild to integration.rs

This commit is contained in:
bitfl0wer 2023-05-21 16:02:54 +02:00
parent f897351994
commit 5af2216882
2 changed files with 31 additions and 50 deletions

View File

@ -114,53 +114,3 @@ impl<'a> types::Guild {
}
}
}
#[cfg(test)]
mod test {
use crate::api::schemas;
use crate::api::types;
use crate::instance::Instance;
#[tokio::test]
async fn guild_creation_deletion() {
let mut instance = Instance::new(crate::URLBundle {
api: "http://localhost:3001/api".to_string(),
wss: "ws://localhost:3001/".to_string(),
cdn: "http://localhost:3001".to_string(),
})
.await
.unwrap();
let login_schema: schemas::LoginSchema = schemas::LoginSchema::new(
schemas::AuthUsername::new("user@test.xyz".to_string()).unwrap(),
"transrights".to_string(),
None,
None,
None,
None,
)
.unwrap();
let mut user = instance.login_account(&login_schema).await.unwrap();
let guild_create_schema = schemas::GuildCreateSchema {
name: Some("test".to_string()),
region: None,
icon: None,
channels: None,
guild_template_code: None,
system_channel_id: None,
rules_channel_id: None,
};
let guild =
types::Guild::create(&mut user, "http://localhost:3001/api", guild_create_schema)
.await
.unwrap();
println!("{}", guild);
match types::Guild::delete(&mut user, "http://localhost:3001/api", guild).await {
None => assert!(true),
Some(_) => assert!(false),
}
}
}

View File

@ -41,3 +41,34 @@ async fn setup() -> TestBundle {
async fn teardown(bundle: TestBundle) {
bundle.user.delete().await;
}
mod guild {
use chorus::api::{schemas, types};
#[tokio::test]
async fn guild_creation_deletion() {
let mut bundle = crate::setup().await;
let guild_create_schema = schemas::GuildCreateSchema {
name: Some("test".to_string()),
region: None,
icon: None,
channels: None,
guild_template_code: None,
system_channel_id: None,
rules_channel_id: None,
};
let guild =
types::Guild::create(&mut bundle.user, bundle.urls.get_api(), guild_create_schema)
.await
.unwrap();
println!("{}", guild);
match types::Guild::delete(&mut bundle.user, bundle.urls.get_api(), guild).await {
None => assert!(true),
Some(_) => assert!(false),
}
}
}