Add local DB resource registration
This commit is contained in:
parent
21920b51b5
commit
4ec50d7473
14 changed files with 313 additions and 8 deletions
|
|
@ -387,6 +387,73 @@ fn keychain_init_and_status_use_local_keychain_log() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn db_add_and_status_register_local_db_metadata() {
|
||||
let home = tempfile::tempdir().expect("tempdir");
|
||||
let paths = geth_config::GethPaths::from_home(home.path());
|
||||
let node = geth_node::init_node(&paths).expect("init node");
|
||||
let db_path = home.path().join("notes.sqlite");
|
||||
std::fs::write(&db_path, b"sqlite placeholder").expect("write db");
|
||||
|
||||
let response = geth_node::handle_request(
|
||||
&node,
|
||||
geth_control::ControlRequest::DbAdd {
|
||||
name: "notes".to_owned(),
|
||||
path: db_path.clone(),
|
||||
},
|
||||
)
|
||||
.expect("add db");
|
||||
match response {
|
||||
geth_control::ControlResponse::DbAdded { db } => {
|
||||
assert_eq!(db.name, "notes");
|
||||
assert_eq!(db.sync_status, "local-only");
|
||||
assert!(db.path_exists);
|
||||
assert_eq!(db.size_bytes, Some(18));
|
||||
}
|
||||
other => panic!("unexpected response: {other:?}"),
|
||||
}
|
||||
|
||||
let response = geth_node::handle_request(
|
||||
&node,
|
||||
geth_control::ControlRequest::DbStatus {
|
||||
name: "notes".to_owned(),
|
||||
},
|
||||
)
|
||||
.expect("db status");
|
||||
match response {
|
||||
geth_control::ControlResponse::DbStatus { db } => {
|
||||
assert_eq!(db.name, "notes");
|
||||
assert!(db.path.ends_with("notes.sqlite"));
|
||||
assert_eq!(
|
||||
db.schema_metadata,
|
||||
"not-inspected-until-crsqlite-integration"
|
||||
);
|
||||
}
|
||||
other => panic!("unexpected response: {other:?}"),
|
||||
}
|
||||
|
||||
assert!(
|
||||
geth_node::handle_request(
|
||||
&node,
|
||||
geth_control::ControlRequest::DbAdd {
|
||||
name: "../bad".to_owned(),
|
||||
path: db_path,
|
||||
},
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
assert!(
|
||||
geth_node::handle_request(
|
||||
&node,
|
||||
geth_control::ControlRequest::DbAdd {
|
||||
name: "missing".to_owned(),
|
||||
path: home.path().join("missing.sqlite"),
|
||||
},
|
||||
)
|
||||
.is_err()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ssh_cert_request_approval_and_revocation_export_use_local_state() {
|
||||
let home = tempfile::tempdir().expect("tempdir");
|
||||
|
|
|
|||
Loading…
Reference in a new issue