added test for listing drivers :D (insulting error message)
This commit is contained in:
@@ -1,13 +1,29 @@
|
|||||||
|
use crate::{driver_data::Driver, pog::SqlStruct};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
use actix_web::{
|
use actix_web::{
|
||||||
http::header::ContentType,
|
http::header::ContentType,
|
||||||
test::{self, init_service},
|
test::{self, init_service},
|
||||||
};
|
};
|
||||||
|
use chrono::NaiveDate;
|
||||||
|
use sqlx::{PgPool, Row};
|
||||||
|
|
||||||
//TODO: sqlx offline mode for these tests
|
//TODO: sqlx offline mode for these tests
|
||||||
#[actix_web::test]
|
#[actix_web::test]
|
||||||
async fn test_list_drivers_ok() {
|
async fn test_list_drivers_ok() {
|
||||||
let app = tests::init_service(App::new().service(driver_data::list_all)).await;
|
dotenv().ok();
|
||||||
|
let database_url = env::var("DATABASE_URL").expect("Put a DB url in the .env file dumbass");
|
||||||
|
let pool = PgPoolOptions::new()
|
||||||
|
.max_connections(10)
|
||||||
|
.connect(database_url.as_str())
|
||||||
|
.await
|
||||||
|
.expect("No pool connection man :(");
|
||||||
|
let app = tests::init_service(
|
||||||
|
App::new()
|
||||||
|
.app_data(web::Data::new(pool.clone()))
|
||||||
|
.service(driver_data::list_all),
|
||||||
|
)
|
||||||
|
.await;
|
||||||
let req = test::TestRequest::get()
|
let req = test::TestRequest::get()
|
||||||
.uri("/api/json/drivers")
|
.uri("/api/json/drivers")
|
||||||
.insert_header(ContentType::plaintext())
|
.insert_header(ContentType::plaintext())
|
||||||
@@ -15,3 +31,4 @@ async fn test_list_drivers_ok() {
|
|||||||
let resp = test::call_service(&app, req).await;
|
let resp = test::call_service(&app, req).await;
|
||||||
assert!(resp.status().is_success());
|
assert!(resp.status().is_success());
|
||||||
}
|
}
|
||||||
|
//TODO: sqlx tests
|
||||||
|
|||||||
Reference in New Issue
Block a user