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