test(swarm-authelia-bridge-sock): pin every response variant's wire shape

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.
This commit is contained in:
atlas 2026-08-19 21:38:57 +02:00
commit e71c9cc431

View file

@ -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(),
})