pub mod pbs;
#[cfg(feature = "pve-context")]
pub mod pve;
+#[cfg(test)]
+mod test;
/// Product-specific context
pub trait Context: Send + Sync + Debug {
fn default_config(&self) -> &'static str;
}
-#[cfg(not(feature = "pve-context"))]
+#[cfg(not(test))]
static CONTEXT: Mutex<Option<&'static dyn Context>> = Mutex::new(None);
-// The test unfortunately require context...
-// TODO: Check if we can make this nicer...
-#[cfg(feature = "pve-context")]
-static CONTEXT: Mutex<Option<&'static dyn Context>> = Mutex::new(Some(&pve::PVE_CONTEXT));
+#[cfg(test)]
+static CONTEXT: Mutex<Option<&'static dyn Context>> = Mutex::new(Some(&test::TestContext));
/// Set the product-specific context
pub fn set_context(context: &'static dyn Context) {
--- /dev/null
+use crate::context::Context;
+
+#[derive(Debug)]
+pub struct TestContext;
+
+impl Context for TestContext {
+ fn lookup_email_for_user(&self, _user: &str) -> Option<String> {
+ Some("test@example.com".into())
+ }
+
+ fn default_sendmail_author(&self) -> String {
+ "Proxmox VE".into()
+ }
+
+ fn default_sendmail_from(&self) -> String {
+ "root".into()
+ }
+
+ fn http_proxy_config(&self) -> Option<String> {
+ None
+ }
+
+ fn default_config(&self) -> &'static str {
+ ""
+ }
+}