Add crsql changes metadata status
This commit is contained in:
parent
e039a4f81f
commit
677945073b
8 changed files with 182 additions and 15 deletions
|
|
@ -399,6 +399,23 @@ fn db_add_and_status_register_local_db_metadata() {
|
|||
[],
|
||||
)
|
||||
.expect("create notes table");
|
||||
conn.execute(
|
||||
r#"CREATE TABLE crsql_changes(
|
||||
table_name TEXT NOT NULL,
|
||||
pk TEXT NOT NULL,
|
||||
cid TEXT NOT NULL,
|
||||
val BLOB,
|
||||
col_version INTEGER NOT NULL,
|
||||
db_version INTEGER NOT NULL
|
||||
)"#,
|
||||
[],
|
||||
)
|
||||
.expect("create crsql_changes");
|
||||
conn.execute(
|
||||
"INSERT INTO crsql_changes(table_name, pk, cid, val, col_version, db_version) VALUES ('notes', '1', 'body', 'hello', 1, 3)",
|
||||
[],
|
||||
)
|
||||
.expect("insert crsql change");
|
||||
drop(conn);
|
||||
|
||||
let response = geth_node::handle_request(
|
||||
|
|
@ -415,8 +432,11 @@ fn db_add_and_status_register_local_db_metadata() {
|
|||
assert_eq!(db.sync_status, "local-only");
|
||||
assert!(db.path_exists);
|
||||
assert!(db.size_bytes.unwrap_or_default() > 0);
|
||||
assert!(db.schema_metadata.contains("tables=1"));
|
||||
assert!(db.schema_metadata.contains("tables=2"));
|
||||
assert!(db.schema_metadata.contains("schema_hash="));
|
||||
assert!(db.crsqlite_changes.available);
|
||||
assert_eq!(db.crsqlite_changes.change_count, Some(1));
|
||||
assert_eq!(db.crsqlite_changes.max_db_version, Some(3));
|
||||
}
|
||||
other => panic!("unexpected response: {other:?}"),
|
||||
}
|
||||
|
|
@ -432,8 +452,13 @@ fn db_add_and_status_register_local_db_metadata() {
|
|||
geth_control::ControlResponse::DbStatus { db } => {
|
||||
assert_eq!(db.name, "notes");
|
||||
assert!(db.path.ends_with("notes.sqlite"));
|
||||
assert!(db.schema_metadata.contains("tables=1"));
|
||||
assert!(db.schema_metadata.contains("tables=2"));
|
||||
assert!(db.schema_metadata.contains("schema_hash="));
|
||||
assert!(
|
||||
db.crsqlite_changes
|
||||
.columns
|
||||
.contains(&"db_version".to_owned())
|
||||
);
|
||||
}
|
||||
other => panic!("unexpected response: {other:?}"),
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue