From 12da5121ff00df3962d5d9ae8d203105ceda3dac Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Mon, 6 Mar 2023 16:20:47 +0100 Subject: [PATCH] schema: predictable order of errors for tests Otherwise we'd have to "search" & match the errors... Signed-off-by: Wolfgang Bumiller --- proxmox-schema/src/de/verify.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/proxmox-schema/src/de/verify.rs b/proxmox-schema/src/de/verify.rs index 8aaf6ee1..71e87b0e 100644 --- a/proxmox-schema/src/de/verify.rs +++ b/proxmox-schema/src/de/verify.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; use std::cell::RefCell; -use std::collections::HashSet; +use std::collections::{BTreeSet, HashSet}; use std::fmt; use std::mem; @@ -229,7 +229,9 @@ impl<'de> de::Visitor<'de> for Visitor { _ => return Err(A::Error::invalid_type(Unexpected::Map, &self)), }; - let mut required_keys = HashSet::<&'static str>::new(); + // The tests need this to be in a predictable order, so HashSet won't work as it uses a + // randomized default state. + let mut required_keys = BTreeSet::<&'static str>::new(); for (key, optional, _schema) in schema.properties() { if !optional { required_keys.insert(key);