Move tests to tests/-dir

This commit is contained in:
bitfl0wer 2023-05-27 22:46:27 +02:00
parent 28663efb09
commit a3c800c3d9
3 changed files with 0 additions and 218 deletions

View File

@ -70,54 +70,3 @@ pub mod login {
}
}
}
/*#[cfg(test)]
mod test {
use crate::api::schemas::schemas::{
AuthEmail, AuthPassword, AuthUsername, LoginSchema, RegisterSchema,
};
use crate::instance::Instance;
use crate::limit::LimitedRequester;
use crate::URLBundle;
#[tokio::test]
async fn test_login() {
let urls = URLBundle::new(
"http://localhost:3001/api".to_string(),
"http://localhost:3001".to_string(),
"http://localhost:3001".to_string(),
);
let limited_requester = LimitedRequester::new(urls.get_api().to_string()).await;
let mut test_instance = Instance::new(urls.clone(), limited_requester)
.await
.unwrap();
let reg = RegisterSchema::new(
AuthUsername::new("TestAccount".to_string()).unwrap(),
Some(AuthPassword::new("transrights".to_string()).unwrap()),
true,
Some(AuthEmail::new("apiauthlogin1@testlogin.xyz".to_string()).unwrap()),
None,
None,
Some("2000-01-01".to_string()),
None,
None,
None,
)
.unwrap();
test_instance.register_account(&reg).await.unwrap().token;
let login_schema = LoginSchema::new(
AuthUsername::new("apiauthlogin1@testlogin.xyz".to_string()).unwrap(),
"transrights".to_string(),
Some(false),
None,
None,
None,
);
let login_result = test_instance
.login_account(&login_schema.unwrap())
.await
.unwrap();
}
}*/

View File

@ -78,36 +78,3 @@ pub mod register {
}
}
}
#[cfg(test)]
mod test {
use crate::instance::Instance;
use crate::limit::LimitedRequester;
use crate::types::RegisterSchema;
use crate::URLBundle;
#[tokio::test]
async fn test_registration() {
let urls = URLBundle::new(
"http://localhost:3001/api".to_string(),
"http://localhost:3001".to_string(),
"http://localhost:3001".to_string(),
);
let _limited_requester = LimitedRequester::new().await;
let mut test_instance = Instance::new(urls.clone()).await.unwrap();
let reg = RegisterSchema::new(
"Hiiii".to_string(),
None,
true,
None,
None,
None,
Some("2000-01-01".to_string()),
None,
None,
None,
)
.unwrap();
let _ = test_instance.register_account(&reg).await.unwrap().token;
}
}

View File

@ -114,137 +114,3 @@ pub mod messages {
}
}
}
#[cfg(test)]
mod test {
use crate::instance::UserMeta;
use crate::types::{LoginSchema, MessageSendSchema, PartialDiscordFileAttachment};
use crate::{instance::Instance};
use std::io::Read;
use std::{cell::RefCell, fs::File};
use std::{io::BufReader, rc::Rc};
#[tokio::test]
async fn send_message() {
let channel_id = "1106954414356168802".to_string();
let mut message = MessageSendSchema::new(
None,
Some("A Message!".to_string()),
None,
None,
None,
None,
None,
None,
None,
None,
);
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: LoginSchema = LoginSchema::new(
"user@test.xyz".to_string(),
"transrights".to_string(),
None,
None,
None,
None,
)
.unwrap();
let login_result = instance.login_account(&login_schema).await.unwrap();
let token = login_result.token;
println!("TOKEN: {}", token);
let settings = login_result.settings;
let limits = instance.limits.clone();
let mut user = UserMeta::new(
Rc::new(RefCell::new(instance)),
token,
limits,
settings,
None,
);
let _ = user
.send_message(&mut message, channel_id, None)
.await
.unwrap();
}
#[tokio::test]
async fn send_message_attachment() {
let channel_id = "1106954414356168802".to_string();
let f = File::open("./README.md").unwrap();
let mut reader = BufReader::new(f);
let mut buffer = Vec::new();
reader.read_to_end(&mut buffer).unwrap();
let attachment = PartialDiscordFileAttachment {
id: None,
filename: "README.md".to_string(),
description: None,
content_type: None,
size: None,
url: None,
proxy_url: None,
width: None,
height: None,
ephemeral: None,
duration_secs: None,
waveform: None,
content: buffer,
};
let mut message = MessageSendSchema::new(
None,
Some("trans rights now".to_string()),
None,
None,
None,
None,
None,
None,
None,
Some(vec![attachment.clone()]),
);
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: LoginSchema = LoginSchema::new(
"user@test.xyz".to_string(),
"transrights".to_string(),
None,
None,
None,
None,
)
.unwrap();
let login_result = instance.login_account(&login_schema).await.unwrap();
let token = login_result.token;
let settings = login_result.settings;
let limits = instance.limits.clone();
let mut user = UserMeta::new(
Rc::new(RefCell::new(instance)),
token,
limits,
settings,
None,
);
let vec_attach = vec![attachment.clone()];
let _arg = Some(&vec_attach);
let response = user
.send_message(&mut message, channel_id, Some(vec![attachment.clone()]))
.await
.unwrap();
println!("[Response:] {}", response.text().await.unwrap());
}
}