kcode_k1_daemon_lib_testkit/
lib.rs1const REQUIRED_LINES: &[&str] = &[
4 "kcode-k1-access = \"0.6.0\"",
5 "kcode-k1-access-full-audio = \"0.9.1\"",
6 "kcode-k1-access-launch-nodes = \"0.2.0\"",
7 "kcode-k1-access-persons = \"0.3.0\"",
8 "kcode-k1-access-profiles = \"0.6.0\"",
9 "kcode-k1-audio-classification = \"0.5.9\"",
10 "kcode-k1-authority-filters = \"0.2.0\"",
11 "kcode-k1-chat-service = \"0.6.0\"",
12 "kcode-k1-daemon-provider-config = \"0.1.4\"",
13 "kcode-k1-full-audio = \"0.3.7\"",
14 "kcode-k1-http-access-context = \"0.2.0\"",
15 "kcode-k1-http-audio = \"0.3.0\"",
16 "kcode-k1-http-audio-artifacts = \"0.3.0\"",
17 "kcode-k1-http-chat = \"0.5.0\"",
18 "kcode-k1-http-launch-nodes = \"0.2.0\"",
19 "kcode-k1-http-people = \"0.9.0\"",
20 "kcode-k1-http-persons = \"0.3.0\"",
21 "kcode-k1-launch-nodes = \"0.3.0\"",
22 "kcode-k1-peering = \"0.3.1\"",
23 "kcode-k1-txn-ordering = \"0.5.1\"",
24];
25
26const OBSOLETE_LINES: &[&str] = &[
27 "kcode-k1-chat-service = \"0.3.0\"",
28 "kcode-k1-http-chat = \"0.2.0\"",
29];
30
31pub fn verify_manifest(manifest: &str) {
33 for required in REQUIRED_LINES {
34 assert!(
35 manifest.lines().any(|line| line == *required),
36 "missing required manifest line: {required}"
37 );
38 }
39 for obsolete in OBSOLETE_LINES {
40 assert!(
41 !manifest.lines().any(|line| line == *obsolete),
42 "obsolete manifest line: {obsolete}"
43 );
44 }
45 assert!(
46 !manifest.lines().any(|line| line.contains(" = \"=")),
47 "manifest contains an exact internal pin"
48 );
49}
50
51#[cfg(test)]
52mod tests {
53 use super::*;
54
55 fn good_manifest() -> String {
56 REQUIRED_LINES.join("\n")
57 }
58
59 #[test]
60 fn accepts_current_manifest() {
61 verify_manifest(&good_manifest());
62 }
63
64 #[test]
65 #[should_panic(expected = "missing required manifest line")]
66 fn rejects_missing_required_line() {
67 verify_manifest(&good_manifest().replacen("kcode-k1-peering = \"0.3.1\"\n", "", 1));
68 }
69
70 #[test]
71 #[should_panic(expected = "obsolete manifest line")]
72 fn rejects_obsolete_line() {
73 verify_manifest(&format!(
74 "{}\nkcode-k1-chat-service = \"0.3.0\"",
75 good_manifest()
76 ));
77 }
78
79 #[test]
80 #[should_panic(expected = "exact internal pin")]
81 fn rejects_exact_internal_pin() {
82 verify_manifest(&format!(
83 "{}\nkcode-k1-peering = \"=0.3.1\"",
84 good_manifest()
85 ));
86 }
87}