Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add db reopen test and don't specify full dependency versions #48

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ path = "src/lib.rs"
crate-type = ["cdylib", "rlib"]

[dependencies]
idb = { version = "0.6.2", features = ["builder"] }
thiserror = "1.0.61"
wasm-bindgen = "0.2.92"
idb = { version = "0.6", features = ["builder"] }
thiserror = "1"
wasm-bindgen = "0.2"

[dev-dependencies]
serde = { version = "1.0.164", features = ["derive"] }
serde_json = "1.0.97"
serde-wasm-bindgen = "0.5.0"
wasm-bindgen-test = "0.3.37"
js-sys = "0.3.69"
num-traits = { version = "0.2.19", default-features = false }
serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde-wasm-bindgen = "0.6"
wasm-bindgen-test = "0.3"
js-sys = "0.3"
num-traits = { version = "0.2", default-features = false }

[profile.release]
# Tell `rustc` to optimize for small code size.
Expand Down
23 changes: 21 additions & 2 deletions tests/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,12 @@ struct InvoiceRequest<'a> {
/// Creates a database
async fn create_db() -> Rexie {
assert!(Rexie::delete("test").await.is_ok());
create_db_with_version(1).await
}

async fn create_db_with_version(version: u32) -> Rexie {
let rexie = Rexie::builder("test")
.version(1)
.version(version)
.add_object_store(
ObjectStore::new("employees")
.key_path("id")
Expand All @@ -69,8 +72,12 @@ async fn create_db() -> Rexie {

/// Checks basic details of the database
async fn basic_test_db(rexie: &Rexie) {
basic_test_db_with_version(rexie, 1).await;
}

async fn basic_test_db_with_version(rexie: &Rexie, version: u32) {
assert_eq!(rexie.name(), "test");
assert_eq!(rexie.version(), Ok(1));
assert_eq!(rexie.version(), Ok(version));
assert_eq!(
rexie.store_names(),
vec!["departments", "employees", "invoices"]
Expand Down Expand Up @@ -524,3 +531,15 @@ async fn test_add_all_pass() {

close_and_delete_db(rexie).await;
}

#[wasm_bindgen_test]
async fn test_db_reopen() {
let rexie = create_db().await;
basic_test_db(&rexie).await;
rexie.close();

let rexie = create_db_with_version(2).await;
basic_test_db_with_version(&rexie, 2).await;

close_and_delete_db(rexie).await;
}
Loading