From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 245721FF170 for ; Tue, 3 Dec 2024 13:23:43 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 46B643152; Tue, 3 Dec 2024 13:23:39 +0100 (CET) From: Christoph Heiss To: pve-devel@lists.proxmox.com Date: Tue, 3 Dec 2024 13:23:27 +0100 Message-ID: <20241203122331.383398-4-c.heiss@proxmox.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241203122331.383398-1-c.heiss@proxmox.com> References: <20241203122331.383398-1-c.heiss@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.027 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [parse-answer.rs, proxmox.com, docs.rs] Subject: [pve-devel] [PATCH installer 3/4] auto-installer: tests: add diff'ed assertions for answer parsing tests X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Adds the `pretty_assertions` crate [0] as dev-dependency, which does this very nicely. This makes failures way easier to observe and quickly reason about. See also [1] for the initial discussion about this. [0] https://docs.rs/pretty_assertions [1] https://lore.proxmox.com/pve-devel/a35eafb9-cbba-4d79-8535-d2bc7c5560ee@proxmox.com/ Signed-off-by: Christoph Heiss --- debian/control | 1 + proxmox-auto-installer/Cargo.toml | 3 +++ proxmox-auto-installer/tests/parse-answer.rs | 6 +++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/debian/control b/debian/control index fd0f4df..ee1fc44 100644 --- a/debian/control +++ b/debian/control @@ -25,6 +25,7 @@ Build-Depends: cargo:native, librust-sha2-0.10-dev, librust-toml-0.8-dev, librust-ureq-2.10-dev, + librust-pretty-assertions-1.4-dev, libtest-mockmodule-perl, patchelf, perl, diff --git a/proxmox-auto-installer/Cargo.toml b/proxmox-auto-installer/Cargo.toml index 7e3d90c..d06478f 100644 --- a/proxmox-auto-installer/Cargo.toml +++ b/proxmox-auto-installer/Cargo.toml @@ -21,3 +21,6 @@ toml.workspace = true clap = { version = "4.0", features = ["derive"] } glob = "0.3" + +[dev-dependencies] +pretty_assertions = "1.4" diff --git a/proxmox-auto-installer/tests/parse-answer.rs b/proxmox-auto-installer/tests/parse-answer.rs index f6450cf..68b3834 100644 --- a/proxmox-auto-installer/tests/parse-answer.rs +++ b/proxmox-auto-installer/tests/parse-answer.rs @@ -1,7 +1,6 @@ -use std::path::{Path, PathBuf}; - use serde_json::Value; use std::fs; +use std::path::{Path, PathBuf}; use proxmox_auto_installer::answer; use proxmox_auto_installer::answer::Answer; @@ -61,7 +60,8 @@ fn run_named_test(name: &str) { let json_path = resource_path.join(format!("parse_answer/{name}.json")); let compare_raw = fs::read_to_string(&json_path).unwrap(); let compare: Value = serde_json::from_str(&compare_raw).unwrap(); - assert_eq!(config, compare); + + pretty_assertions::assert_eq!(config, compare); } mod tests { -- 2.47.0 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel