all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Christoph Heiss <c.heiss@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH installer 4/6] tui, common: move network option tests to correct crate
Date: Thu, 27 Mar 2025 16:17:15 +0100	[thread overview]
Message-ID: <20250327151718.1084841-5-c.heiss@proxmox.com> (raw)
In-Reply-To: <20250327151718.1084841-1-c.heiss@proxmox.com>

The `NetworkOptions` struct was moved here in

  5362c05cd ("common: copy common code from tui-installer")

and

  86c48f76f ("tui: switch to common crate")

but the tests were forgotten at the original place.

No functional changes.

Signed-off-by: Christoph Heiss <c.heiss@proxmox.com>
---
 proxmox-installer-common/Cargo.toml     |  3 +
 proxmox-installer-common/src/options.rs | 88 +++++++++++++++++++++++
 proxmox-tui-installer/Cargo.toml        |  3 -
 proxmox-tui-installer/src/options.rs    | 93 -------------------------
 4 files changed, 91 insertions(+), 96 deletions(-)

diff --git a/proxmox-installer-common/Cargo.toml b/proxmox-installer-common/Cargo.toml
index c220f01..4bdb2b0 100644
--- a/proxmox-installer-common/Cargo.toml
+++ b/proxmox-installer-common/Cargo.toml
@@ -31,3 +31,6 @@ http = [
     "dep:sha2",
     "dep:ureq"
 ]
+
+[dev-dependencies]
+pretty_assertions = "1.4"
diff --git a/proxmox-installer-common/src/options.rs b/proxmox-installer-common/src/options.rs
index 6ebf64c..28f2971 100644
--- a/proxmox-installer-common/src/options.rs
+++ b/proxmox-installer-common/src/options.rs
@@ -497,6 +497,12 @@ pub fn email_validate(email: &str) -> Result<()> {
 #[cfg(test)]
 mod tests {
     use super::*;
+    use crate::{
+        setup::{Dns, Gateway, Interface, InterfaceState, NetworkInfo, Routes, SetupInfo},
+        utils::CidrAddress,
+    };
+    use std::collections::BTreeMap;
+    use std::net::{IpAddr, Ipv4Addr};
 
     #[test]
     fn zfs_arc_limit() {
@@ -520,4 +526,86 @@ mod tests {
             assert_eq!(default_zfs_arc_max(ProxmoxProduct::PDM, *total_memory), 0);
         }
     }
+
+    #[test]
+    fn network_options_from_setup_network_info() {
+        let setup = SetupInfo::mocked();
+
+        let mut interfaces = BTreeMap::new();
+        interfaces.insert(
+            "eth0".to_owned(),
+            Interface {
+                name: "eth0".to_owned(),
+                index: 0,
+                state: InterfaceState::Up,
+                mac: "01:23:45:67:89:ab".to_owned(),
+                addresses: Some(vec![
+                    CidrAddress::new(Ipv4Addr::new(192, 168, 0, 2), 24).unwrap(),
+                ]),
+            },
+        );
+
+        let mut info = NetworkInfo {
+            dns: Dns {
+                domain: Some("bar.com".to_owned()),
+                dns: Vec::new(),
+            },
+            routes: Some(Routes {
+                gateway4: Some(Gateway {
+                    dev: "eth0".to_owned(),
+                    gateway: IpAddr::V4(Ipv4Addr::new(192, 168, 0, 1)),
+                }),
+                gateway6: None,
+            }),
+            interfaces,
+            hostname: Some("foo".to_owned()),
+        };
+
+        pretty_assertions::assert_eq!(
+            NetworkOptions::defaults_from(&setup, &info),
+            NetworkOptions {
+                ifname: "eth0".to_owned(),
+                fqdn: Fqdn::from("foo.bar.com").unwrap(),
+                address: CidrAddress::new(Ipv4Addr::new(192, 168, 0, 2), 24).unwrap(),
+                gateway: IpAddr::V4(Ipv4Addr::new(192, 168, 0, 1)),
+                dns_server: Ipv4Addr::UNSPECIFIED.into(),
+            }
+        );
+
+        info.hostname = None;
+        pretty_assertions::assert_eq!(
+            NetworkOptions::defaults_from(&setup, &info),
+            NetworkOptions {
+                ifname: "eth0".to_owned(),
+                fqdn: Fqdn::from("pve.bar.com").unwrap(),
+                address: CidrAddress::new(Ipv4Addr::new(192, 168, 0, 2), 24).unwrap(),
+                gateway: IpAddr::V4(Ipv4Addr::new(192, 168, 0, 1)),
+                dns_server: Ipv4Addr::UNSPECIFIED.into(),
+            }
+        );
+
+        info.dns.domain = None;
+        pretty_assertions::assert_eq!(
+            NetworkOptions::defaults_from(&setup, &info),
+            NetworkOptions {
+                ifname: "eth0".to_owned(),
+                fqdn: Fqdn::from("pve.example.invalid").unwrap(),
+                address: CidrAddress::new(Ipv4Addr::new(192, 168, 0, 2), 24).unwrap(),
+                gateway: IpAddr::V4(Ipv4Addr::new(192, 168, 0, 1)),
+                dns_server: Ipv4Addr::UNSPECIFIED.into(),
+            }
+        );
+
+        info.hostname = Some("foo".to_owned());
+        pretty_assertions::assert_eq!(
+            NetworkOptions::defaults_from(&setup, &info),
+            NetworkOptions {
+                ifname: "eth0".to_owned(),
+                fqdn: Fqdn::from("foo.example.invalid").unwrap(),
+                address: CidrAddress::new(Ipv4Addr::new(192, 168, 0, 2), 24).unwrap(),
+                gateway: IpAddr::V4(Ipv4Addr::new(192, 168, 0, 1)),
+                dns_server: Ipv4Addr::UNSPECIFIED.into(),
+            }
+        );
+    }
 }
diff --git a/proxmox-tui-installer/Cargo.toml b/proxmox-tui-installer/Cargo.toml
index 0e9c940..403d1ef 100644
--- a/proxmox-tui-installer/Cargo.toml
+++ b/proxmox-tui-installer/Cargo.toml
@@ -14,6 +14,3 @@ serde_json.workspace = true
 regex.workspace = true
 
 cursive = { version = "0.21", default-features = false, features = ["crossterm-backend"] }
-
-[dev-dependencies]
-pretty_assertions = "1.4"
diff --git a/proxmox-tui-installer/src/options.rs b/proxmox-tui-installer/src/options.rs
index 8dcd697..c80877f 100644
--- a/proxmox-tui-installer/src/options.rs
+++ b/proxmox-tui-installer/src/options.rs
@@ -79,96 +79,3 @@ impl InstallerOptions {
         ]
     }
 }
-
-#[cfg(test)]
-mod tests {
-    use super::*;
-    use proxmox_installer_common::{
-        setup::{Dns, Gateway, Interface, InterfaceState, NetworkInfo, Routes, SetupInfo},
-        utils::{CidrAddress, Fqdn},
-    };
-    use std::collections::BTreeMap;
-    use std::net::{IpAddr, Ipv4Addr};
-
-    #[test]
-    fn network_options_from_setup_network_info() {
-        let setup = SetupInfo::mocked();
-
-        let mut interfaces = BTreeMap::new();
-        interfaces.insert(
-            "eth0".to_owned(),
-            Interface {
-                name: "eth0".to_owned(),
-                index: 0,
-                state: InterfaceState::Up,
-                mac: "01:23:45:67:89:ab".to_owned(),
-                addresses: Some(vec![
-                    CidrAddress::new(Ipv4Addr::new(192, 168, 0, 2), 24).unwrap(),
-                ]),
-            },
-        );
-
-        let mut info = NetworkInfo {
-            dns: Dns {
-                domain: Some("bar.com".to_owned()),
-                dns: Vec::new(),
-            },
-            routes: Some(Routes {
-                gateway4: Some(Gateway {
-                    dev: "eth0".to_owned(),
-                    gateway: IpAddr::V4(Ipv4Addr::new(192, 168, 0, 1)),
-                }),
-                gateway6: None,
-            }),
-            interfaces,
-            hostname: Some("foo".to_owned()),
-        };
-
-        pretty_assertions::assert_eq!(
-            NetworkOptions::defaults_from(&setup, &info),
-            NetworkOptions {
-                ifname: "eth0".to_owned(),
-                fqdn: Fqdn::from("foo.bar.com").unwrap(),
-                address: CidrAddress::new(Ipv4Addr::new(192, 168, 0, 2), 24).unwrap(),
-                gateway: IpAddr::V4(Ipv4Addr::new(192, 168, 0, 1)),
-                dns_server: Ipv4Addr::UNSPECIFIED.into(),
-            }
-        );
-
-        info.hostname = None;
-        pretty_assertions::assert_eq!(
-            NetworkOptions::defaults_from(&setup, &info),
-            NetworkOptions {
-                ifname: "eth0".to_owned(),
-                fqdn: Fqdn::from("pve.bar.com").unwrap(),
-                address: CidrAddress::new(Ipv4Addr::new(192, 168, 0, 2), 24).unwrap(),
-                gateway: IpAddr::V4(Ipv4Addr::new(192, 168, 0, 1)),
-                dns_server: Ipv4Addr::UNSPECIFIED.into(),
-            }
-        );
-
-        info.dns.domain = None;
-        pretty_assertions::assert_eq!(
-            NetworkOptions::defaults_from(&setup, &info),
-            NetworkOptions {
-                ifname: "eth0".to_owned(),
-                fqdn: Fqdn::from("pve.example.invalid").unwrap(),
-                address: CidrAddress::new(Ipv4Addr::new(192, 168, 0, 2), 24).unwrap(),
-                gateway: IpAddr::V4(Ipv4Addr::new(192, 168, 0, 1)),
-                dns_server: Ipv4Addr::UNSPECIFIED.into(),
-            }
-        );
-
-        info.hostname = Some("foo".to_owned());
-        pretty_assertions::assert_eq!(
-            NetworkOptions::defaults_from(&setup, &info),
-            NetworkOptions {
-                ifname: "eth0".to_owned(),
-                fqdn: Fqdn::from("foo.example.invalid").unwrap(),
-                address: CidrAddress::new(Ipv4Addr::new(192, 168, 0, 2), 24).unwrap(),
-                gateway: IpAddr::V4(Ipv4Addr::new(192, 168, 0, 1)),
-                dns_server: Ipv4Addr::UNSPECIFIED.into(),
-            }
-        );
-    }
-}
-- 
2.48.1



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


  parent reply	other threads:[~2025-03-27 15:18 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-27 15:17 [pve-devel] [PATCH installer 0/6] fix #5811: add option to retrieve FQDN from DHCP configuration Christoph Heiss
2025-03-27 15:17 ` [pve-devel] [PATCH installer 1/6] auto: utils: avoid a force unwrap() Christoph Heiss
2025-04-04 12:51   ` [pve-devel] applied: " Thomas Lamprecht
2025-03-27 15:17 ` [pve-devel] [PATCH installer 2/6] auto: tests: parse-answer: allow per-test runtime env Christoph Heiss
2025-04-04 12:51   ` [pve-devel] applied: " Thomas Lamprecht
2025-03-27 15:17 ` [pve-devel] [PATCH installer 3/6] auto: tests: allow testing for serde parse errors of answer files Christoph Heiss
2025-04-04 12:51   ` [pve-devel] applied: " Thomas Lamprecht
2025-03-27 15:17 ` Christoph Heiss [this message]
2025-04-04 12:54   ` [pve-devel] [PATCH installer 4/6] tui, common: move network option tests to correct crate Thomas Lamprecht
2025-03-27 15:17 ` [pve-devel] [PATCH installer 5/6] common: options: allow user-supplied domain for network options Christoph Heiss
2025-03-27 15:17 ` [pve-devel] [PATCH installer 6/6] fix #5811: auto: add option to retrieve FQDN from DHCP configuration Christoph Heiss
2025-04-01 13:15   ` Daniel Kral
2025-04-01 13:25     ` Christoph Heiss
2025-04-01 13:29       ` Stefan Hanreich
2025-04-01 13:44         ` Daniel Kral
2025-04-01 14:58           ` Thomas Lamprecht
2025-04-01 13:45 ` [pve-devel] [PATCH installer 0/6] fix #5811: " Daniel Kral
2025-04-01 14:05   ` Christoph Heiss

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250327151718.1084841-5-c.heiss@proxmox.com \
    --to=c.heiss@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal