refactor: Implement unified search abstraction, MemoryState refactoring, error handling, and unit test expansion

This commit is contained in:
Riz Ashraf committed 2026-10-01 08:37:52 +01:00
1 parent a34554b7ff
commit 462f65f66d
21 files changed
+425 -535

No files matched your search

+6 -6
View File
@@ -180,13 +180,13 @@ mod tests {
}
});
let res = update_handler.execute(args, state.clone()).await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
let res = update_handler.execute(args, state.clone()).await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
assert_eq!(res, "Env fingerprint updated");
let read_handler = ReadEnvFingerprintHandler;
let res2 = read_handler
.execute(json!({"namespace": "global"}), state.clone())
.await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
.await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
assert!(res2.contains("rustc"));
assert!(res2.contains("1.70.0"));
}
@@ -211,7 +211,7 @@ mod tests {
let handler = GetEnvironmentDetailsHandler;
let res = handler
.execute(json!({"namespace": "global"}), state.clone())
.await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
.await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
assert!(res.contains("global"));
}
@@ -230,7 +230,7 @@ mod tests {
"context": "For database access",
"namespace": "global"
});
let res1 = req_handler.execute(args_req, state.clone()).await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
let res1 = req_handler.execute(args_req, state.clone()).await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
assert_eq!(res1, "Env requirement logged");
let reg_handler = RegisterEnvironmentHandler;
@@ -241,13 +241,13 @@ mod tests {
"requires_vpn": true,
"namespace": "global"
});
let res2 = reg_handler.execute(args_reg, state.clone()).await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
let res2 = reg_handler.execute(args_reg, state.clone()).await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
assert_eq!(res2, "Environment registered");
let get_handler = GetEnvironmentDetailsHandler;
let res3 = get_handler
.execute(json!({"namespace": "global"}), state.clone())
.await.map_err(|e| crate::error::AppError::Internal(e.to_string()))?;
.await.map_err(|e| crate::error::AppError::Internal(e.to_string())).unwrap();
assert!(res3.contains("prod.local"));
assert!(!res3.is_empty());
}