add test for bind binary not null constraint

This commit is contained in:
Alexey Proshutinskiy 2021-09-02 13:05:11 +03:00
parent f821a3c891
commit 9553388096
3 changed files with 61 additions and 0 deletions

19
Config.toml Normal file
View File

@ -0,0 +1,19 @@
modules_dir = "artifacts/"
[[module]]
name = "sqlite3"
mem_pages_count = 100
logger_enabled = false
[module.wasi]
preopened_files = ["/tmp"]
mapped_dirs = { "tmp" = "/tmp" }
[[module]]
name = "test"
mem_pages_count = 1
logger_enabled = false
[module.wasi]
preopened_files = ["/tmp"]
mapped_dirs = { "tmp" = "/tmp" }

19
build.sh Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -o errexit -o nounset -o pipefail
# set current working directory to script directory to run script from everywhere
cd "$(dirname "$0")"
# build aqua-dht.wasm
marine build --release
# copy .wasm to artifacts
rm -f artifacts/*
mkdir -p artifacts
cp target/wasm32-wasi/release/test.wasm artifacts/
# download SQLite 3 to use in tests
curl -L https://github.com/fluencelabs/sqlite/releases/download/v0.14.0_w/sqlite3.wasm -o artifacts/sqlite3.wasm
# generate Aqua bindings
#marine aqua artifacts/aqua-dht.wasm -s AquaDHT -i aqua-dht >../aqua/dht.aqua

View File

@ -84,3 +84,26 @@ pub fn test3() {
println!("age = {}", row[1].as_integer().unwrap()); println!("age = {}", row[1].as_integer().unwrap());
} }
} }
#[marine]
pub fn test4() {
use marine_sqlite_connector::Value;
let connection = marine_sqlite_connector::open(":memory:").unwrap();
connection
.execute(
"
CREATE TABLE users (name TEXT, age BLOB NOT NULL);
",
)
.unwrap();
let mut cursor = connection
.prepare("INSERT OR REPLACE INTO users VALUES (?, ?)").unwrap();
cursor.bind(1, &Value::Integer(50)).unwrap();
cursor.bind(2, &Value::Binary(vec![1, 2, 3])).unwrap();
cursor.next().unwrap();
}