mirror of
https://github.com/fluencelabs/sqlite-wasm-connector
synced 2025-04-21 07:02:13 +00:00
Test opening a read-only connection
This commit is contained in:
parent
9328fa0897
commit
d1e9f8fd3e
@ -188,7 +188,7 @@ impl ConnectionFlags {
|
|||||||
|
|
||||||
/// Open the database for reading only.
|
/// Open the database for reading only.
|
||||||
pub fn set_read_only(mut self) -> Self {
|
pub fn set_read_only(mut self) -> Self {
|
||||||
self.0 |= ffi::SQLITE_OPEN_READWRITE;
|
self.0 |= ffi::SQLITE_OPEN_READONLY;
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
18
tests/lib.rs
18
tests/lib.rs
@ -1,7 +1,7 @@
|
|||||||
extern crate sqlite;
|
extern crate sqlite;
|
||||||
extern crate temporary;
|
extern crate temporary;
|
||||||
|
|
||||||
use sqlite::{Connection, State, Type, Value};
|
use sqlite::{Connection, ConnectionFlags, State, Type, Value};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
macro_rules! ok(($result:expr) => ($result.unwrap()));
|
macro_rules! ok(($result:expr) => ($result.unwrap()));
|
||||||
@ -40,6 +40,22 @@ fn connection_iterate() {
|
|||||||
assert!(done);
|
assert!(done);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn connection_open_with_flags() {
|
||||||
|
use temporary::Directory;
|
||||||
|
|
||||||
|
let directory = ok!(Directory::new("sqlite"));
|
||||||
|
let path = directory.path().join("database.sqlite3");
|
||||||
|
setup_users(&path);
|
||||||
|
|
||||||
|
let flags = ConnectionFlags::new().set_read_only();
|
||||||
|
let connection = ok!(sqlite::open_with_flags(path, flags));
|
||||||
|
match connection.execute("INSERT INTO users VALUES (2, 'Bob', NULL, NULL)") {
|
||||||
|
Err(_) => {},
|
||||||
|
_ => unreachable!(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn connection_set_busy_handler() {
|
fn connection_set_busy_handler() {
|
||||||
use std::thread;
|
use std::thread;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user