From ae1709dafd22ac3c64441472e90df8799253292e Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Wed, 14 Jun 2023 21:18:24 +0100 Subject: Key values (#1038) * wip * Start testing * Store host IDs, not hostnames Why? Hostnames can change a lot, and therefore host filtering can be funky. Really, all we want is a unique ID per machine + do not care what it might be. * Mostly just write a fuckload of tests * Add a v0 kv store I can push to * Appending works * Add next() and iterate, test the pointer chain * Fix sig * Make clippy happy and thaw the ICE * Fix tests' * Fix tests * typed builder and cleaner db trait --------- Co-authored-by: Conrad Ludgate --- atuin-client/src/database.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'atuin-client/src/database.rs') diff --git a/atuin-client/src/database.rs b/atuin-client/src/database.rs index 22bd5886..a2d8c533 100644 --- a/atuin-client/src/database.rs +++ b/atuin-client/src/database.rs @@ -17,13 +17,14 @@ use sqlx::{ use super::{ history::History, ordering, - settings::{FilterMode, SearchMode}, + settings::{FilterMode, SearchMode, Settings}, }; pub struct Context { pub session: String, pub cwd: String, pub hostname: String, + pub host_id: String, } #[derive(Default, Clone)] @@ -50,11 +51,13 @@ pub fn current_context() -> Context { env::var("ATUIN_HOST_USER").unwrap_or_else(|_| whoami::username()) ); let cwd = utils::get_current_dir(); + let host_id = Settings::host_id().expect("failed to load host ID"); Context { session, hostname, cwd, + host_id, } } @@ -551,6 +554,7 @@ mod test { hostname: "test:host".to_string(), session: "beepboopiamasession".to_string(), cwd: "/home/ellie".to_string(), + host_id: "test-host".to_string(), }; let results = db @@ -757,6 +761,7 @@ mod test { hostname: "test:host".to_string(), session: "beepboopiamasession".to_string(), cwd: "/home/ellie".to_string(), + host_id: "test-host".to_string(), }; let mut db = Sqlite::new("sqlite::memory:").await.unwrap(); -- cgit v1.3.1