const REQUIRED_LINES: &[&str] = &[
"kcode-k1-access = \"0.6.1\"",
"kcode-k1-access-full-audio = \"0.9.1\"",
"kcode-k1-access-launch-nodes = \"0.2.0\"",
"kcode-k1-access-persons = \"0.3.0\"",
"kcode-k1-access-profiles = \"0.6.2\"",
"kcode-k1-audio-classification = \"0.5.9\"",
"kcode-k1-authority-filters = \"0.2.0\"",
"kcode-k1-chat-service = \"0.6.0\"",
"kcode-k1-daemon-provider-config = \"0.1.4\"",
"kcode-k1-full-audio = \"0.3.7\"",
"kcode-k1-http-access-context = \"0.2.0\"",
"kcode-k1-http-access-profile-presentation = \"0.1.0\"",
"kcode-k1-http-audio = \"0.3.0\"",
"kcode-k1-http-audio-artifacts = \"0.3.0\"",
"kcode-k1-http-chat = \"0.5.0\"",
"kcode-k1-http-launch-nodes = \"0.2.0\"",
"kcode-k1-http-people = \"0.9.0\"",
"kcode-k1-http-persons = \"0.3.0\"",
"kcode-k1-launch-nodes = \"0.3.0\"",
"kcode-k1-peering = \"0.3.1\"",
"kcode-k1-txn-ordering = \"0.5.1\"",
];
const OBSOLETE_LINES: &[&str] = &[
"kcode-k1-chat-service = \"0.3.0\"",
"kcode-k1-http-chat = \"0.2.0\"",
];
pub fn verify_manifest(manifest: &str) {
for required in REQUIRED_LINES {
assert!(
manifest.lines().any(|line| line == *required),
"missing required manifest line: {required}"
);
}
for obsolete in OBSOLETE_LINES {
assert!(
!manifest.lines().any(|line| line == *obsolete),
"obsolete manifest line: {obsolete}"
);
}
assert!(
!manifest.lines().any(|line| line.contains(" = \"=")),
"manifest contains an exact internal pin"
);
}
#[cfg(test)]
mod tests {
use super::*;
fn good_manifest() -> String {
REQUIRED_LINES.join("\n")
}
#[test]
fn accepts_current_manifest() {
verify_manifest(&good_manifest());
}
#[test]
#[should_panic(expected = "missing required manifest line")]
fn rejects_missing_required_line() {
verify_manifest(&good_manifest().replacen(
"kcode-k1-http-access-profile-presentation = \"0.1.0\"\n",
"",
1,
));
}
#[test]
#[should_panic(expected = "obsolete manifest line")]
fn rejects_obsolete_line() {
verify_manifest(&format!(
"{}\nkcode-k1-chat-service = \"0.3.0\"",
good_manifest()
));
}
#[test]
#[should_panic(expected = "exact internal pin")]
fn rejects_exact_internal_pin() {
verify_manifest(&format!(
"{}\nkcode-k1-peering = \"=0.3.1\"",
good_manifest()
));
}
}