From 346611d376ba8e0202713c21c3ea868f5da38fc2 Mon Sep 17 00:00:00 2001 From: Leonardo Forchini Date: Fri, 25 Sep 2026 08:10:01 +0000 Subject: [PATCH] Drop tests that only restate constructors and defaults These tests do not provide any value so they are removed. Future component tests will exercise the same behaviour in more realistic contexts. Signed-off-by: Leonardo Forchini --- src/config.rs | 10 ---------- src/engines/mod.rs | 24 ------------------------ src/engines/threshold.rs | 22 ---------------------- src/instance.rs | 12 ------------ src/util.rs | 27 --------------------------- 5 files changed, 95 deletions(-) diff --git a/src/config.rs b/src/config.rs index 5f4f796..a78deaf 100644 --- a/src/config.rs +++ b/src/config.rs @@ -272,16 +272,6 @@ mod tests { assert!(matches!(err, ConfigError::SerdeJson(_))); } - /// Test that pretty-printed default JSON includes engine, poll - /// interval, and engine config path. - #[test] - fn dump_default_config_contains_engine() { - let dumped = dump_default_config(); - assert!(dumped.contains(r#""engine": "threshold""#)); - assert!(dumped.contains(r#""scale_poll_secs": 10.0"#)); - assert!(dumped.contains(r#""/etc/io-thread-controller.d/engines""#)); - } - /// Test that serde defaults for min/max threads, host CPU ceiling, /// and cooldown match `Config::default()`. #[test] diff --git a/src/engines/mod.rs b/src/engines/mod.rs index e96fac2..6855e0e 100644 --- a/src/engines/mod.rs +++ b/src/engines/mod.rs @@ -247,30 +247,6 @@ pub fn load_registered_engine( mod tests { use super::*; - /// Test that `ScaleAction::target`/`Display` cover None/Up/Down - /// variants. - #[test] - fn scale_action_target_and_display() { - assert_eq!(ScaleAction::None.target(), None); - assert_eq!(ScaleAction::Up(4).target(), Some(4)); - assert_eq!(ScaleAction::Down(2).target(), Some(2)); - assert_eq!(ScaleAction::Revert(3).target(), Some(3)); - - assert_eq!(ScaleAction::None.to_string(), "none"); - assert_eq!(ScaleAction::Up(1).to_string(), "up"); - assert_eq!(ScaleAction::Down(1).to_string(), "down"); - assert_eq!(ScaleAction::Revert(1).to_string(), "revert"); - } - - /// Test that `InstanceDecision::new` stores the VM id and - /// `ScaleAction` unchanged. - #[test] - fn instance_decision_new_preserves_fields() { - let decision = InstanceDecision::new("vm-1", ScaleAction::Up(5)); - assert_eq!(decision.instance_id, "vm-1"); - assert_eq!(decision.decision, ScaleAction::Up(5)); - } - /// Test that registry loads the threshold engine by name and errors /// on unknown engines. #[test] diff --git a/src/engines/threshold.rs b/src/engines/threshold.rs index cfe08f1..6aa2b70 100644 --- a/src/engines/threshold.rs +++ b/src/engines/threshold.rs @@ -765,26 +765,4 @@ mod tests { ScaleAction::Revert(4) ); } - - /// Test that a missing `threshold.json` still builds an engine with - /// defaults. - #[test] - fn missing_config_file_uses_defaults() { - let dir = tempfile::tempdir().unwrap(); - let engine = - ThresholdEngine::from_config_dir(&Path::new(dir.path().to_str().unwrap())).unwrap(); - assert_eq!(engine.name(), super::ENGINE_NAME); - let _ = engine.config(); - } - - /// Test that CPU utilisation below scale-up/down thresholds yields - /// Hold/`None`. - #[rstest] - #[tokio::test] - async fn evaluate_holds_when_util_below_thresholds(#[future] instance: Arc) { - let instance = instance.await; - let engine = ThresholdEngine::new(ThresholdConfig::default()); - let action = engine.evaluate(&instance, &context()).await; - assert_eq!(action, ScaleAction::None); - } } diff --git a/src/instance.rs b/src/instance.rs index 2f74c1b..8b87723 100644 --- a/src/instance.rs +++ b/src/instance.rs @@ -662,18 +662,6 @@ mod tests { assert!(closed.load(Ordering::Relaxed)); } - /// Test that `Display` for an instance prints the bare VM id. - #[test] - fn display_trims_instance_id() { - let instance = Instance::new( - " vm-1 ".to_string(), - Path::new(""), - 1, - SnapshotClient { threads: 1 }, - ); - assert_eq!(instance.to_string(), "vm-1"); - } - use super::{TaskCpuSample, compute_per_worker_util}; fn task(tid: i32, name: &str, cpu_ticks: u64) -> TaskCpuSample { diff --git a/src/util.rs b/src/util.rs index 49667f2..68bac0e 100644 --- a/src/util.rs +++ b/src/util.rs @@ -141,30 +141,3 @@ macro_rules! path { } }; } - -#[cfg(test)] -mod tests { - use super::*; - - /// Test that relative `Path` values are stored unchanged. - #[test] - fn relative_paths_are_unchanged() { - let path = Path::new("relative/sock"); - assert_eq!(path.as_os_str(), OsStr::new("relative/sock")); - } - - /// Test that absolute `Path` values stay absolute under the default - /// root. - #[test] - fn absolute_paths_keep_absolute_form_under_default_root() { - let path = Path::new("/var/run/example.sock"); - assert_eq!(path.as_os_str(), OsStr::new("/var/run/example.sock")); - } - - /// Test that `FromStr` builds a `Path` from a string. - #[test] - fn from_str_builds_path() { - let path: Path = "tmp/example".parse().unwrap(); - assert_eq!(path.as_os_str(), OsStr::new("tmp/example")); - } -}