From e71c9cc43175619913ac31a1a96d56cc70bc0fd9 Mon Sep 17 00:00:00 2001 From: atlas Date: Wed, 19 Aug 2026 21:38:57 +0200 Subject: [PATCH] test(swarm-authelia-bridge-sock): pin every response variant's wire shape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test named for pinning the external tag covered all but the newest variant, and two doc comments still counted three outcomes where there are four. Folded the missing variant in rather than editing the number: a test that claims to settle the wire shape and quietly omits one is worse than a narrower one, because the next variant gets added with nothing to point its author here. The counts are gone rather than corrected — prose that counts its subject is falsified by every addition and is invisible to a grep for the vocabulary that changed. --- swarm-authelia-bridge-sock/src/lib.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/swarm-authelia-bridge-sock/src/lib.rs b/swarm-authelia-bridge-sock/src/lib.rs index 890669f9..849961cd 100644 --- a/swarm-authelia-bridge-sock/src/lib.rs +++ b/swarm-authelia-bridge-sock/src/lib.rs @@ -75,7 +75,7 @@ pub struct AgentIdentity { /// The bridge's answer to a [`BridgeRequest`]. /// /// `#[serde(tag = "status")]` rather than a bare `Result`-shaped wrapper: an -/// external tag reads directly as one of three named outcomes on the wire +/// external tag reads directly as a named outcome on the wire /// (`{"status":"created",...}`), with no separate "was this an error" /// boolean to keep in sync with which variant it is. #[derive(Debug, Clone, Serialize, Deserialize)] @@ -111,8 +111,13 @@ mod tests { use super::{AgentIdentity, BridgeRequest, BridgeResponse}; /// Pins the external-tag wire shape — a reader off the wire (or a log - /// line) should be able to tell the three outcomes apart without + /// line) should be able to tell the outcomes apart without /// cross-referencing this crate's source. + /// + /// **Every variant, deliberately.** A test that claims to pin the wire + /// shape and covers all but one is worse than a narrower one: the next + /// variant gets added with nothing to remind its author that this is + /// where the shape is settled. #[test] fn response_variants_tag_on_status() { let created = serde_json::to_value(BridgeResponse::Created).unwrap(); @@ -121,6 +126,17 @@ mod tests { let exists = serde_json::to_value(BridgeResponse::AlreadyExists).unwrap(); assert_eq!(exists, serde_json::json!({"status": "already_exists"})); + let agents = serde_json::to_value(BridgeResponse::Agents { + agents: vec![AgentIdentity { + name: "atlas".to_owned(), + }], + }) + .unwrap(); + assert_eq!( + agents, + serde_json::json!({"status": "agents", "agents": [{"name": "atlas"}]}) + ); + let err = serde_json::to_value(BridgeResponse::Error { message: "boom".to_owned(), })