first integrated unit test to start replacing bash test suite
This commit is contained in:
parent
da01c13ac5
commit
14f91e2240
@ -134,10 +134,45 @@ pub async fn create(pool: &Pool, response: &mut Response<Body>, params: Value) {
|
||||
};
|
||||
|
||||
match insert_new_invite(&pool, &invite).await {
|
||||
Ok(_) => *response.body_mut() = Body::from("yes"),
|
||||
Ok(_) => {},
|
||||
Err(mysqle) => {
|
||||
println!("\tINVITES::CREATE::ERROR: {}", mysqle);
|
||||
*response.status_mut() = StatusCode::BAD_REQUEST;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod invites_test {
|
||||
/*
|
||||
* INVITE CREATION
|
||||
* Good - Bad - Malicious
|
||||
*/
|
||||
|
||||
use crate::testing::{get_pool, hyper_resp};
|
||||
use hyper::StatusCode;
|
||||
use serde_json::Value;
|
||||
|
||||
#[tokio::test]
|
||||
async fn create_invite_good() {
|
||||
// Generation of data
|
||||
let p = get_pool();
|
||||
let mut resp = hyper_resp();
|
||||
// expected params
|
||||
let params: Value = serde_json::from_str(r#"
|
||||
{
|
||||
"uses": 3,
|
||||
"expire": null
|
||||
}
|
||||
"#).unwrap();
|
||||
|
||||
// Collection
|
||||
super::join(&p, &mut resp, params).await;
|
||||
let _ = p.disconnect().await;
|
||||
|
||||
// Analysis - todo
|
||||
assert_eq!(StatusCode::OK, resp.status());
|
||||
println!("Body contents (should be nothing) => {:?}", resp.body());
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ use mysql_async::Pool;
|
||||
use dotenv::dotenv;
|
||||
use clap::{Arg, App};
|
||||
|
||||
mod testing;
|
||||
mod auth;
|
||||
use auth::AuthReason;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user