mirror of
https://github.com/fluencelabs/sqlite-wasm-connector
synced 2025-03-14 22:10:49 +00:00
add test, fix minor issues
This commit is contained in:
parent
63e9952194
commit
83a32e9046
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "marine-sqlite-connector"
|
name = "marine-sqlite-connector"
|
||||||
version = "0.7.0"
|
version = "0.8.0"
|
||||||
license = "Apache-2.0/MIT"
|
license = "Apache-2.0/MIT"
|
||||||
authors = [
|
authors = [
|
||||||
"Daniel Dulaney <ddy@vitronic.com>",
|
"Daniel Dulaney <ddy@vitronic.com>",
|
||||||
@ -37,7 +37,9 @@ path = "src/test.rs"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
marine-rs-sdk = "0.7.0"
|
marine-rs-sdk = "0.7.0"
|
||||||
|
bytesize = "1.2.0"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
temporary = "0.6"
|
|
||||||
marine-rs-sdk-test = "0.2.0"
|
marine-rs-sdk-test = "0.2.0"
|
||||||
|
temporary = "0.6"
|
||||||
|
|
||||||
|
@ -314,7 +314,7 @@ fn last_error(raw: ffi::Sqlite3DbHandle) -> Option<Error> {
|
|||||||
/// to stay below the limit, it will exceed the limit rather than generate an SQLITE_NOMEM error.
|
/// to stay below the limit, it will exceed the limit rather than generate an SQLITE_NOMEM error.
|
||||||
/// In other words, the soft heap limit is advisory only.
|
/// In other words, the soft heap limit is advisory only.
|
||||||
pub fn soft_soft_heap_limit64(limit: i64) -> i64 {
|
pub fn soft_soft_heap_limit64(limit: i64) -> i64 {
|
||||||
unsafe { ffi::sqlite3_hard_heap_limit64(limit) }
|
unsafe { ffi::sqlite3_soft_heap_limit64(limit) }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// From the SQLite docs:
|
/// From the SQLite docs:
|
||||||
|
39
src/test.rs
39
src/test.rs
@ -1,5 +1,5 @@
|
|||||||
use marine_rs_sdk::marine;
|
use marine_rs_sdk::marine;
|
||||||
use marine_sqlite_connector::{version, State, Value};
|
use marine_sqlite_connector::{version, Connection, State, Value};
|
||||||
|
|
||||||
pub fn main() {}
|
pub fn main() {}
|
||||||
|
|
||||||
@ -648,3 +648,40 @@ pub fn test12() {
|
|||||||
assert_eq!(row[4].as_string().unwrap(), "UPDATE");
|
assert_eq!(row[4].as_string().unwrap(), "UPDATE");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[marine]
|
||||||
|
pub fn test13() {
|
||||||
|
fn insert_data(connection: &Connection) -> marine_sqlite_connector::Result<()> {
|
||||||
|
connection
|
||||||
|
.execute("INSERT INTO email VALUES ('Alice', 'How deep is the hole', 'Nobody knows')")
|
||||||
|
}
|
||||||
|
|
||||||
|
let connection = marine_sqlite_connector::open(":memory:").unwrap();
|
||||||
|
|
||||||
|
connection
|
||||||
|
.execute(
|
||||||
|
"
|
||||||
|
CREATE TABLE email(sender, subject, body);
|
||||||
|
",
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
for _ in 0..10 {
|
||||||
|
let insert_result = insert_data(&connection);
|
||||||
|
assert!(insert_result.is_ok());
|
||||||
|
}
|
||||||
|
|
||||||
|
marine_sqlite_connector::set_hard_heap_limit64(bytesize::KB as i64);
|
||||||
|
|
||||||
|
for _ in 0..10 {
|
||||||
|
let insert_result = insert_data(&connection);
|
||||||
|
assert!(insert_result.is_err());
|
||||||
|
}
|
||||||
|
|
||||||
|
marine_sqlite_connector::set_hard_heap_limit64(bytesize::MB as i64);
|
||||||
|
|
||||||
|
for _ in 0..10 {
|
||||||
|
let insert_result = insert_data(&connection);
|
||||||
|
assert!(insert_result.is_ok());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -76,4 +76,9 @@ mod tests {
|
|||||||
fn test12(test: marine_test_env::test::ModuleInterface) {
|
fn test12(test: marine_test_env::test::ModuleInterface) {
|
||||||
test.test12()
|
test.test12()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[marine_test(config_path = "../Config.toml", modules_dir = "../artifacts/")]
|
||||||
|
fn test13(test: marine_test_env::test::ModuleInterface) {
|
||||||
|
test.test13()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user