use std::fs;
use std::path::PathBuf;
fn docs_dir() -> PathBuf {
PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("docs")
}
#[allow(clippy::expect_used)] fn read_doc(relative: &str) -> String {
let path = docs_dir().join(relative);
fs::read_to_string(&path)
.expect("doc file must be readable")
.replace("\r\n", "\n")
}
#[test]
fn deployment_guide_points_at_releasing_runbook() {
let deployment = read_doc("DEPLOYMENT.md");
assert!(
deployment.contains("runbooks/RELEASING.md"),
"docs/DEPLOYMENT.md must link to docs/runbooks/RELEASING.md as the \
authoritative release procedure"
);
}
#[test]
fn releasing_runbook_links_back_to_deployment_guide() {
let releasing = read_doc("runbooks/RELEASING.md");
assert!(
releasing.contains("DEPLOYMENT.md"),
"docs/runbooks/RELEASING.md must link back to docs/DEPLOYMENT.md for \
the broader deployment/distribution overview"
);
}
#[test]
fn releasing_runbook_does_not_send_readers_back_for_secrets() {
let releasing = read_doc("runbooks/RELEASING.md");
let link_marker = "](../DEPLOYMENT.md)";
let after_link = releasing
.split_once(link_marker)
.expect("releasing_runbook_links_back_to_deployment_guide already asserts this link exists")
.1;
let overview_clause = after_link.split('.').next().unwrap_or("");
assert!(
!overview_clause.to_lowercase().contains("secret"),
"docs/runbooks/RELEASING.md's pointer to docs/DEPLOYMENT.md must not \
claim DEPLOYMENT.md covers secrets -- RELEASING.md's own Required \
Secrets table is the authoritative source"
);
}
#[test]
fn deployment_guide_does_not_duplicate_the_release_procedure() {
let deployment = read_doc("DEPLOYMENT.md");
let duplicated_markers = [
"### 1. Prepare Release",
"### 2. Open and Merge the Release PR",
"### 3. Tag the Release on",
"## Rollback\n",
"### Release Workflow Fails",
"### Docker Build Fails",
"### Publish to crates.io Fails",
"## Best Practices",
];
for marker in duplicated_markers {
assert!(
!deployment.contains(marker),
"docs/DEPLOYMENT.md re-introduced duplicated release-procedure \
content ({marker:?}); this content belongs solely in \
docs/runbooks/RELEASING.md"
);
}
}
#[test]
fn deployment_guide_states_the_scope_boundary() {
let deployment = read_doc("DEPLOYMENT.md");
assert!(
deployment.contains("Scope boundary"),
"docs/DEPLOYMENT.md must explicitly state its scope boundary against \
docs/runbooks/RELEASING.md"
);
}