mirror of
https://github.com/fluencelabs/sqlite-wasm-connector
synced 2025-04-25 08:42:14 +00:00
Simplify a few tests
This commit is contained in:
parent
0a6ed63a04
commit
ec7ce0c27c
@ -13,8 +13,8 @@ connection
|
|||||||
.execute(
|
.execute(
|
||||||
"
|
"
|
||||||
CREATE TABLE users (name TEXT, age INTEGER);
|
CREATE TABLE users (name TEXT, age INTEGER);
|
||||||
INSERT INTO users (name, age) VALUES ('Alice', 42);
|
INSERT INTO users VALUES ('Alice', 42);
|
||||||
INSERT INTO users (name, age) VALUES ('Bob', 69);
|
INSERT INTO users VALUES ('Bob', 69);
|
||||||
",
|
",
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
16
src/lib.rs
16
src/lib.rs
@ -11,8 +11,8 @@
|
|||||||
//! .execute(
|
//! .execute(
|
||||||
//! "
|
//! "
|
||||||
//! CREATE TABLE users (name TEXT, age INTEGER);
|
//! CREATE TABLE users (name TEXT, age INTEGER);
|
||||||
//! INSERT INTO users (name, age) VALUES ('Alice', 42);
|
//! INSERT INTO users VALUES ('Alice', 42);
|
||||||
//! INSERT INTO users (name, age) VALUES ('Bob', 69);
|
//! INSERT INTO users VALUES ('Bob', 69);
|
||||||
//! ",
|
//! ",
|
||||||
//! )
|
//! )
|
||||||
//! .unwrap();
|
//! .unwrap();
|
||||||
@ -26,8 +26,8 @@
|
|||||||
//! # .execute(
|
//! # .execute(
|
||||||
//! # "
|
//! # "
|
||||||
//! # CREATE TABLE users (name TEXT, age INTEGER);
|
//! # CREATE TABLE users (name TEXT, age INTEGER);
|
||||||
//! # INSERT INTO users (name, age) VALUES ('Alice', 42);
|
//! # INSERT INTO users VALUES ('Alice', 42);
|
||||||
//! # INSERT INTO users (name, age) VALUES ('Bob', 69);
|
//! # INSERT INTO users VALUES ('Bob', 69);
|
||||||
//! # ",
|
//! # ",
|
||||||
//! # )
|
//! # )
|
||||||
//! # .unwrap();
|
//! # .unwrap();
|
||||||
@ -51,8 +51,8 @@
|
|||||||
//! # .execute(
|
//! # .execute(
|
||||||
//! # "
|
//! # "
|
||||||
//! # CREATE TABLE users (name TEXT, age INTEGER);
|
//! # CREATE TABLE users (name TEXT, age INTEGER);
|
||||||
//! # INSERT INTO users (name, age) VALUES ('Alice', 42);
|
//! # INSERT INTO users VALUES ('Alice', 42);
|
||||||
//! # INSERT INTO users (name, age) VALUES ('Bob', 69);
|
//! # INSERT INTO users VALUES ('Bob', 69);
|
||||||
//! # ",
|
//! # ",
|
||||||
//! # )
|
//! # )
|
||||||
//! # .unwrap();
|
//! # .unwrap();
|
||||||
@ -79,8 +79,8 @@
|
|||||||
//! # .execute(
|
//! # .execute(
|
||||||
//! # "
|
//! # "
|
||||||
//! # CREATE TABLE users (name TEXT, age INTEGER);
|
//! # CREATE TABLE users (name TEXT, age INTEGER);
|
||||||
//! # INSERT INTO users (name, age) VALUES ('Alice', 42);
|
//! # INSERT INTO users VALUES ('Alice', 42);
|
||||||
//! # INSERT INTO users (name, age) VALUES ('Bob', 69);
|
//! # INSERT INTO users VALUES ('Bob', 69);
|
||||||
//! # ",
|
//! # ",
|
||||||
//! # )
|
//! # )
|
||||||
//! # .unwrap();
|
//! # .unwrap();
|
||||||
|
20
tests/lib.rs
20
tests/lib.rs
@ -55,7 +55,7 @@ fn connection_set_busy_handler() {
|
|||||||
thread::spawn(move || {
|
thread::spawn(move || {
|
||||||
let mut connection = ok!(sqlite::open(&path));
|
let mut connection = ok!(sqlite::open(&path));
|
||||||
ok!(connection.set_busy_handler(|_| true));
|
ok!(connection.set_busy_handler(|_| true));
|
||||||
let statement = "INSERT INTO users (id, name, age, photo) VALUES (?, ?, ?, ?)";
|
let statement = "INSERT INTO users VALUES (?, ?, ?, ?)";
|
||||||
let mut statement = ok!(connection.prepare(statement));
|
let mut statement = ok!(connection.prepare(statement));
|
||||||
ok!(statement.bind(1, 2i64));
|
ok!(statement.bind(1, 2i64));
|
||||||
ok!(statement.bind(2, "Bob"));
|
ok!(statement.bind(2, "Bob"));
|
||||||
@ -137,7 +137,7 @@ fn cursor_workflow() {
|
|||||||
#[test]
|
#[test]
|
||||||
fn statement_bind() {
|
fn statement_bind() {
|
||||||
let connection = setup_users(":memory:");
|
let connection = setup_users(":memory:");
|
||||||
let statement = "INSERT INTO users (id, name, age, photo) VALUES (?, ?, ?, ?)";
|
let statement = "INSERT INTO users VALUES (?, ?, ?, ?)";
|
||||||
let mut statement = ok!(connection.prepare(statement));
|
let mut statement = ok!(connection.prepare(statement));
|
||||||
|
|
||||||
ok!(statement.bind(1, 2i64));
|
ok!(statement.bind(1, 2i64));
|
||||||
@ -234,13 +234,13 @@ fn setup_english<T: AsRef<Path>>(path: T) -> Connection {
|
|||||||
ok!(connection.execute(
|
ok!(connection.execute(
|
||||||
"
|
"
|
||||||
CREATE TABLE english (value TEXT);
|
CREATE TABLE english (value TEXT);
|
||||||
INSERT INTO english (value) VALUES ('cerotype');
|
INSERT INTO english VALUES ('cerotype');
|
||||||
INSERT INTO english (value) VALUES ('metatype');
|
INSERT INTO english VALUES ('metatype');
|
||||||
INSERT INTO english (value) VALUES ('ozotype');
|
INSERT INTO english VALUES ('ozotype');
|
||||||
INSERT INTO english (value) VALUES ('phenotype');
|
INSERT INTO english VALUES ('phenotype');
|
||||||
INSERT INTO english (value) VALUES ('plastotype');
|
INSERT INTO english VALUES ('plastotype');
|
||||||
INSERT INTO english (value) VALUES ('undertype');
|
INSERT INTO english VALUES ('undertype');
|
||||||
INSERT INTO english (value) VALUES ('nonsence');
|
INSERT INTO english VALUES ('nonsence');
|
||||||
",
|
",
|
||||||
));
|
));
|
||||||
connection
|
connection
|
||||||
@ -251,7 +251,7 @@ fn setup_users<T: AsRef<Path>>(path: T) -> Connection {
|
|||||||
ok!(connection.execute(
|
ok!(connection.execute(
|
||||||
"
|
"
|
||||||
CREATE TABLE users (id INTEGER, name TEXT, age REAL, photo BLOB);
|
CREATE TABLE users (id INTEGER, name TEXT, age REAL, photo BLOB);
|
||||||
INSERT INTO users (id, name, age, photo) VALUES (1, 'Alice', 42.69, X'4269');
|
INSERT INTO users VALUES (1, 'Alice', 42.69, X'4269');
|
||||||
",
|
",
|
||||||
));
|
));
|
||||||
connection
|
connection
|
||||||
|
Loading…
x
Reference in New Issue
Block a user