2022-10-26 09:32:45 +00:00
|
|
|
#[cfg(test)]
|
2024-04-16 09:39:52 +00:00
|
|
|
#[cfg(all(feature = "diesel_sqlite_pool"))]
|
2022-10-26 09:32:45 +00:00
|
|
|
mod sqlite_shutdown_test {
|
|
|
|
use rocket::{async_test, Build, Rocket};
|
|
|
|
use rocket_sync_db_pools::database;
|
|
|
|
|
|
|
|
#[database("test")]
|
|
|
|
struct Pool(diesel::SqliteConnection);
|
|
|
|
|
|
|
|
async fn rocket() -> Rocket<Build> {
|
|
|
|
use rocket::figment::{util::map, Figment};
|
|
|
|
|
|
|
|
let options = map!["url" => ":memory:"];
|
|
|
|
let config = Figment::from(rocket::Config::debug_default())
|
2024-03-19 03:19:00 +00:00
|
|
|
.merge(("port", 0))
|
2022-10-26 09:32:45 +00:00
|
|
|
.merge(("databases", map!["test" => &options]));
|
|
|
|
|
|
|
|
rocket::custom(config).attach(Pool::fairing())
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_shutdown() {
|
|
|
|
let _rocket = async_test(
|
|
|
|
async {
|
|
|
|
let rocket = rocket().await.ignite().await.expect("unable to ignite");
|
|
|
|
// request shutdown
|
|
|
|
rocket.shutdown().notify();
|
|
|
|
rocket.launch().await.expect("unable to launch")
|
|
|
|
}
|
|
|
|
);
|
|
|
|
// _rocket is dropped here after the runtime is dropped
|
|
|
|
}
|
|
|
|
}
|