Skip to content

Commit

Permalink
got tests to pass
Browse files Browse the repository at this point in the history
  • Loading branch information
darioalessandro committed Nov 25, 2023
1 parent 8b01977 commit a2b9cd3
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions actix-api/tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ mod common;
use actix_api::get_app;
use actix_web::test;

use types::HelloResponse;
/// Test login inserts pkce_challenge, pkce_verifier, csrf_state
/// And returns a login url with the pkce_challenge
///
Expand All @@ -12,8 +13,17 @@ async fn test_login() {
println!("DB_URL: {}", db_url);
common::dbmate_up(&db_url);
let mut app = test::init_service(get_app()).await;
let req = test::TestRequest::get().uri("/login").to_request();
let req = test::TestRequest::get().uri("/hello/dario").to_request();
let resp = test::call_service(&mut app, req).await;
drop(app);
assert!(resp.status() == 302);
assert_eq!(resp.status(), 200);
// Get body as json
let body = test::read_body(resp).await;
let body = String::from_utf8(body.to_vec()).unwrap();
let body: HelloResponse = serde_json::from_str(&body).unwrap();
assert_eq!(
body,
HelloResponse {
name: "dario".to_string()
}
);
}

0 comments on commit a2b9cd3

Please sign in to comment.