rs-zero 0.2.6

Rust-first microservice framework inspired by go-zero engineering practices
Documentation
#![cfg(feature = "db-sqlite")]

use rs_zero::db::{DatabaseConfig, connect_pool, health_check, run_transaction};

#[tokio::test]
async fn sqlite_pool_health_and_transaction_helper_work() {
    let pool = connect_pool(&DatabaseConfig::default())
        .await
        .expect("pool");
    health_check(&pool).await.expect("health");
    let value = run_transaction(&pool, |pool| async move {
        sqlx::query("CREATE TABLE users (id INTEGER PRIMARY KEY)")
            .execute(&pool)
            .await?;
        sqlx::query("INSERT INTO users (id) VALUES (1)")
            .execute(&pool)
            .await?;
        let count: (i64,) = sqlx::query_as("SELECT COUNT(*) FROM users")
            .fetch_one(&pool)
            .await?;
        Ok(count.0)
    })
    .await
    .expect("transaction");
    assert_eq!(value, 1);
}