test (backend-rs): add database connection test

This commit is contained in:
naskya 2024-06-10 21:44:25 +09:00
parent fa9643013e
commit e5448bae33
No known key found for this signature in database
GPG key ID: 712D413B3A9FED5C

View file

@ -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();
}
}