pub async fn testing_client() -> rocket::local::asynchronous::Client {
use rocket::local::asynchronous::Client;
Client::tracked(nidobyte::rocket())
.await
.expect("cannot create rocket testing instance")
}
pub static TEST_USER_PASSWORD: &str = "password";
use nidobyte::{database::Database, models::users::User};
pub async fn user(db: &rocket::State<Database>) -> nidobyte::models::users::User {
use rand::Rng;
const CHARSET: &[u8] = b"abcdefghijklmnopqrstuvwxyz0123456789";
let mut rng = rand::thread_rng();
let username: String = (0..12)
.map(|_| {
let idx = rng.gen_range(0..CHARSET.len());
CHARSET[idx] as char
})
.collect();
User::create(
db,
username.clone(),
TEST_USER_PASSWORD.to_string(),
format!("{}@nidobyte.test", username.clone()),
)
.await
.unwrap()
}