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 74CC01FF14C for ; Fri, 29 May 2026 15:40:03 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 21077C3F1; Fri, 29 May 2026 15:39:59 +0200 (CEST) From: Lukas Wagner To: pdm-devel@lists.proxmox.com Subject: [PATCH datacenter-manager 3/6] task cache: tests: add get_cutoff helper Date: Fri, 29 May 2026 15:39:48 +0200 Message-ID: <20260529133951.326103-4-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260529133951.326103-1-l.wagner@proxmox.com> References: <20260529133951.326103-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1780061964593 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.053 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: SNOO4MIMWDFQEJR7HEASADIGHJAP2K7Z X-Message-ID-Hash: SNOO4MIMWDFQEJR7HEASADIGHJAP2K7Z X-MailFrom: l.wagner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This avoids a little bit of code duplication of the hard-coded remote and node names. Signed-off-by: Lukas Wagner --- server/src/remote_tasks/task_cache.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/server/src/remote_tasks/task_cache.rs b/server/src/remote_tasks/task_cache.rs index fb544c6a..7da92e31 100644 --- a/server/src/remote_tasks/task_cache.rs +++ b/server/src/remote_tasks/task_cache.rs @@ -1301,6 +1301,13 @@ mod tests { cache.update(tasks, &node_map, HashSet::new()) } + fn get_cutoff(cache: &WritableTaskCache) -> i64 { + cache + .read_state() + .cutoff_timestamp("pve-remote", "pve") + .unwrap_or(0) + } + const DEFAULT_MAX_SIZE: u64 = 10000; #[test] @@ -1322,10 +1329,7 @@ mod tests { add_tasks(&cache, vec![task(1000, Some(1010)), task(1001, Some(1011))])?; - assert_eq!( - cache.read_state().cutoff_timestamp("pve-remote", "pve"), - Some(1001) - ); + assert_eq!(get_cutoff(&cache), 1001); cache.rotate(1500)?; @@ -1334,10 +1338,7 @@ mod tests { add_tasks(&cache, vec![task(1500, Some(1510)), task(1501, Some(1511))])?; add_tasks(&cache, vec![task(1200, Some(1210)), task(1300, Some(1310))])?; - assert_eq!( - cache.read_state().cutoff_timestamp("pve-remote", "pve"), - Some(1501), - ); + assert_eq!(get_cutoff(&cache), 1501); cache.rotate(2000)?; assert_eq!(cache.cache.archive_files(&cache.lock)?.len(), 3); -- 2.47.3