I'm running some integration tests but then I noticed I was using the same AppBuilder
across all the functions in the tests
module in my login.rs
. For eg.
// tests/login.rs
#[cfg(test)]
mod tests {
use actix_web::{test, web, App};
// use myproject::utils;
use super::*;
#[actix_web::test]
async fn test_login_get() {
let app = test::init_service(
App::new().service(
web::scope("login")
.service(
web::resource("club")
.route(web::get().to(utils::login::login_club))
.route(web::post().to(utils::login::login_club_post))
)
)
).await;
// Running some tests...
}
#[actix_web::test]
async fn test_login_post() {
let app = test::init_service(
// Would use the same AppBuilder in the above test function
).await;
// Running some tests...
}
}
I thought of probably using lazy_static
but I'm unsure how to use it or if this would be the right use case.