all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Lukas Wagner <l.wagner@proxmox.com>
To: pdm-devel@lists.proxmox.com
Subject: [pdm-devel] [PATCH datacenter-manager 4/8] pdm-api-types: remote upid: add basic tests for RemoteUpid ser/deserialization
Date: Tue, 11 Nov 2025 11:50:55 +0100	[thread overview]
Message-ID: <20251111105059.148997-5-l.wagner@proxmox.com> (raw)
In-Reply-To: <20251111105059.148997-1-l.wagner@proxmox.com>

Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
---
 lib/pdm-api-types/src/remote_upid.rs | 53 ++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/lib/pdm-api-types/src/remote_upid.rs b/lib/pdm-api-types/src/remote_upid.rs
index b4a32769..454c9b1f 100644
--- a/lib/pdm-api-types/src/remote_upid.rs
+++ b/lib/pdm-api-types/src/remote_upid.rs
@@ -104,3 +104,56 @@ impl fmt::Display for RemoteUpid {
 
 serde_plain::derive_deserialize_from_fromstr!(RemoteUpid, "valid remote upid");
 serde_plain::derive_serialize_from_display!(RemoteUpid);
+
+#[cfg(test)]
+mod tests {
+    use super::*;
+
+    #[test]
+    fn test_from_str() {
+        let pve_upid: RemoteUpid =
+            "pve-remote!UPID:pve:00039E4D:002638B8:67B4A9D1:stopall::root@pam:"
+                .parse()
+                .unwrap();
+
+        assert_eq!(pve_upid.remote(), "pve-remote");
+        assert_eq!(
+            pve_upid.upid(),
+            "UPID:pve:00039E4D:002638B8:67B4A9D1:stopall::root@pam:"
+        );
+
+        let pbs_upid: RemoteUpid =
+            "pbs-remote!UPID:pbs:000002B2:00000158:00000000:674D828C:logrotate::root@pam:"
+                .parse()
+                .unwrap();
+
+        assert_eq!(pbs_upid.remote(), "pbs-remote");
+        assert_eq!(
+            pbs_upid.upid(),
+            "UPID:pbs:000002B2:00000158:00000000:674D828C:logrotate::root@pam:"
+        );
+    }
+
+    #[test]
+    fn test_display() {
+        let pve_upid = RemoteUpid {
+            remote: "pve-remote".to_string(),
+            upid: "UPID:pve:00039E4D:002638B8:67B4A9D1:stopall::root@pam:".to_string(),
+        };
+
+        assert_eq!(
+            pve_upid.to_string(),
+            "pve-remote!UPID:pve:00039E4D:002638B8:67B4A9D1:stopall::root@pam:"
+        );
+
+        let pbs_upid = RemoteUpid {
+            remote: "pbs-remote".to_string(),
+            upid: "UPID:pbs:000002B2:00000158:00000000:674D828C:logrotate::root@pam:".to_string(),
+        };
+
+        assert_eq!(
+            pbs_upid.to_string(),
+            "pbs-remote!UPID:pbs:000002B2:00000158:00000000:674D828C:logrotate::root@pam:"
+        );
+    }
+}
-- 
2.47.3



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


  parent reply	other threads:[~2025-11-11 10:50 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-11 10:50 [pdm-devel] [PATCH/RFC datacenter-manager 0/8] add type field to RemoteUpid Lukas Wagner
2025-11-11 10:50 ` [pdm-devel] [PATCH datacenter-manager 1/8] pdm-api-types: move RemoteUpid to its own module Lukas Wagner
2025-11-11 10:50 ` [pdm-devel] [PATCH datacenter-manager 2/8] pdm-api-types: remote upid: make upid field private Lukas Wagner
2025-11-11 10:50 ` [pdm-devel] [PATCH datacenter-manager 3/8] pdm-api-types: remote upid: add missing doc strings Lukas Wagner
2025-11-11 10:50 ` Lukas Wagner [this message]
2025-11-11 10:50 ` [pdm-devel] [RFC datacenter-manager 5/8] pdm-api-types: remote upid: add type field to RemoteUpid Lukas Wagner
2025-11-12 20:00   ` Thomas Lamprecht
2025-11-11 10:50 ` [pdm-devel] [RFC datacenter-manager 6/8] pdm-api-types: remote upid: allow to get native UPID type Lukas Wagner
2025-11-11 10:50 ` [pdm-devel] [RFC datacenter-manager 7/8] ui: remote tasks: use correct base url for PBS tasks Lukas Wagner
2025-11-11 10:50 ` [pdm-devel] [RFC datacenter-manager 8/8] remote task cache: handle PBS tasks correctly Lukas Wagner
2025-11-12 15:50 ` [pdm-devel] [PATCH/RFC datacenter-manager 0/8] add type field to RemoteUpid Shannon Sterz
2025-11-12 20:27 ` [pdm-devel] applied-series: " Thomas Lamprecht

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=20251111105059.148997-5-l.wagner@proxmox.com \
    --to=l.wagner@proxmox.com \
    --cc=pdm-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