test (backend-rs): add database connection test
This commit is contained in:
parent
fa9643013e
commit
e5448bae33
1 changed files with 16 additions and 0 deletions
|
@ -39,6 +39,7 @@ pub async fn get_conn() -> Result<&'static DbConn, DbErr> {
|
|||
#[cfg(test)]
|
||||
mod unit_test {
|
||||
use super::get_conn;
|
||||
use sea_orm::{prelude::*, DbBackend, Statement};
|
||||
|
||||
#[tokio::test]
|
||||
async fn connect_sequential() {
|
||||
|
@ -66,4 +67,19 @@ mod unit_test {
|
|||
task.await.unwrap().unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn access() {
|
||||
// DO NOT write any raw SQL query in the actual program
|
||||
// (with the exception of PGroonga features)
|
||||
get_conn()
|
||||
.await
|
||||
.unwrap()
|
||||
.execute(Statement::from_string(
|
||||
DbBackend::Postgres,
|
||||
"SELECT version()",
|
||||
))
|
||||
.await
|
||||
.unwrap();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue