[pve-devel] [PATCH installer 1/6] tui: options: simplify unit-test setup

Christoph Heiss c.heiss at proxmox.com
Mon Dec 9 13:45:54 CET 2024


We already have `SetupInfo::mocked()` since commit c3c9282 ("common: add
mocked variants for setup and ISO related info structs"), so use that.

Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
 proxmox-tui-installer/src/options.rs | 26 +++-----------------------
 1 file changed, 3 insertions(+), 23 deletions(-)

diff --git a/proxmox-tui-installer/src/options.rs b/proxmox-tui-installer/src/options.rs
index e2116d2..8c882b7 100644
--- a/proxmox-tui-installer/src/options.rs
+++ b/proxmox-tui-installer/src/options.rs
@@ -84,35 +84,15 @@ impl InstallerOptions {
 mod tests {
     use super::*;
     use proxmox_installer_common::{
-        setup::{
-            Dns, Gateway, Interface, InterfaceState, IsoInfo, IsoLocations, NetworkInfo,
-            ProductConfig, ProxmoxProduct, Routes, SetupInfo,
-        },
+        setup::{Dns, Gateway, Interface, InterfaceState, NetworkInfo, Routes, SetupInfo},
         utils::{CidrAddress, Fqdn},
     };
+    use std::collections::BTreeMap;
     use std::net::{IpAddr, Ipv4Addr};
-    use std::{collections::BTreeMap, path::PathBuf};
-
-    fn dummy_setup_info() -> SetupInfo {
-        SetupInfo {
-            config: ProductConfig {
-                fullname: "Proxmox VE".to_owned(),
-                product: ProxmoxProduct::PVE,
-                enable_btrfs: true,
-            },
-            iso_info: IsoInfo {
-                release: String::new(),
-                isorelease: String::new(),
-            },
-            locations: IsoLocations {
-                iso: PathBuf::new(),
-            },
-        }
-    }
 
     #[test]
     fn network_options_from_setup_network_info() {
-        let setup = dummy_setup_info();
+        let setup = SetupInfo::mocked();
 
         let mut interfaces = BTreeMap::new();
         interfaces.insert(
-- 
2.47.0





More information about the pve-devel mailing list