wasm-sql 0.1.6

Wasmtime host implementation for a SQL component WIT interface. Enables Wasm components to interact with SQL databases via the WebAssembly Component Model.
Documentation
#![cfg(any(feature = "sqlite", feature = "sqlite-unbundled"))]

use std::process::Command;
use std::sync::Arc;

use wasm_sql::sqldb::sqlx::sqlite::SqlitePoolOptions;
use wasm_sql::sqldb::SqlDB;

#[macro_use]
mod common;

async fn instantiate() -> anyhow::Result<common::TestHarness> {
    let pool = SqlitePoolOptions::new()
        .max_connections(1)
        .connect("sqlite::memory:")
        .await?;

    common::TestHarness::new(Arc::new(SqlDB::new(pool)), ())
}

#[ctor::ctor]
fn build_guest_component() {
    let status = Command::new("cargo")
        .args([
            "+nightly",
            "build",
            "--manifest-path",
            "tests/sqlite-tests/Cargo.toml",
            "--target",
            "wasm32-wasip2",
        ])
        .status()
        .expect("Failed to run cargo build for SQLite guest component");

    if !status.success() {
        panic!("SQLite guest component build failed");
    }
}

mod bindings {
    wasmtime::component::bindgen!({
        world: "test:sqlite/sqlite-tests",
        path: ["./wit", "./wit/sqlite", "./tests/sqlite-tests/wit"],
    });
}

const WASM_PATH: &str = "target/wasm32-wasip2/debug/sqlite_tests.wasm";

wasm_sql_tests!(bindings::SqliteTests, test_sqlite_tests {
    test_codec_int64,
    test_codec_float64,
    test_codec_string,
    test_codec_blob,
    test_codec_bool,
    test_codec_json,
    test_codec_uuid,
    test_codec_uuid_blob,
    test_codec_date,
    test_codec_time,
    test_codec_datetime,
    test_codec_datetime_utc,
    test_codec_nulls,
});