[pve-devel] [PATCH installer 4/4] tui: use pretty_assertions for object equal asserts

Christoph Heiss c.heiss at proxmox.com
Tue Dec 3 13:23:28 CET 2024


Using the previously introduced `pretty_assertions` crates for object
comparisons improves developer UX quite a bit, making failures easier to
observe and quickly reason about.

Signed-off-by: Christoph Heiss <c.heiss at proxmox.com>
---
 proxmox-tui-installer/Cargo.toml     | 3 +++
 proxmox-tui-installer/src/options.rs | 8 ++++----
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/proxmox-tui-installer/Cargo.toml b/proxmox-tui-installer/Cargo.toml
index 4b11576..3db7d73 100644
--- a/proxmox-tui-installer/Cargo.toml
+++ b/proxmox-tui-installer/Cargo.toml
@@ -14,3 +14,6 @@ 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 b14ecf7..e2116d2 100644
--- a/proxmox-tui-installer/src/options.rs
+++ b/proxmox-tui-installer/src/options.rs
@@ -144,7 +144,7 @@ mod tests {
             hostname: Some("foo".to_owned()),
         };
 
-        assert_eq!(
+        pretty_assertions::assert_eq!(
             NetworkOptions::defaults_from(&setup, &info),
             NetworkOptions {
                 ifname: "eth0".to_owned(),
@@ -156,7 +156,7 @@ mod tests {
         );
 
         info.hostname = None;
-        assert_eq!(
+        pretty_assertions::assert_eq!(
             NetworkOptions::defaults_from(&setup, &info),
             NetworkOptions {
                 ifname: "eth0".to_owned(),
@@ -168,7 +168,7 @@ mod tests {
         );
 
         info.dns.domain = None;
-        assert_eq!(
+        pretty_assertions::assert_eq!(
             NetworkOptions::defaults_from(&setup, &info),
             NetworkOptions {
                 ifname: "eth0".to_owned(),
@@ -180,7 +180,7 @@ mod tests {
         );
 
         info.hostname = Some("foo".to_owned());
-        assert_eq!(
+        pretty_assertions::assert_eq!(
             NetworkOptions::defaults_from(&setup, &info),
             NetworkOptions {
                 ifname: "eth0".to_owned(),
-- 
2.47.0





More information about the pve-devel mailing list