mirror of
https://github.com/rwf2/Rocket.git
synced 2025-02-16 13:42:05 +00:00
26 lines
655 B
Rust
26 lines
655 B
Rust
|
#![cfg(feature = "diesel_sqlite_pool")]
|
||
|
|
||
|
use rocket::figment::Figment;
|
||
|
use rocket_sync_db_pools::database;
|
||
|
|
||
|
#[database("example")]
|
||
|
struct ExampleDb(diesel::SqliteConnection);
|
||
|
|
||
|
#[test]
|
||
|
fn can_drop_connection_in_sync_context() {
|
||
|
let conn = rocket::execute(async {
|
||
|
let figment = Figment::from(rocket::Config::debug_default())
|
||
|
.merge(("databases.example.url", ":memory:"));
|
||
|
|
||
|
let rocket = rocket::custom(figment)
|
||
|
.attach(ExampleDb::fairing())
|
||
|
.ignite().await
|
||
|
.expect("rocket");
|
||
|
|
||
|
ExampleDb::get_one(&rocket).await
|
||
|
.expect("attach => connection")
|
||
|
});
|
||
|
|
||
|
drop(conn);
|
||
|
}
|