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