kcode_k1_daemon_lib_testkit/
lib.rs1#![forbid(unsafe_code)]
2
3const REQUIRED_LINES: &[&str] = &[
4 "kcode-k1-access = \"0.6.2\"",
5 "kcode-k1-access-audio-classifier = \"0.1.0\"",
6 "kcode-k1-access-full-audio = \"0.9.4\"",
7 "kcode-k1-access-launch-nodes = \"0.2.2\"",
8 "kcode-k1-access-persons = \"0.3.0\"",
9 "kcode-k1-access-profiles = \"0.6.2\"",
10 "kcode-k1-audio-classification = \"0.5.10\"",
11 "kcode-k1-audio-classifier = \"0.1.1\"",
12 "kcode-k1-authority-filters = \"0.2.0\"",
13 "kcode-k1-chat-service = \"0.10.1\"",
14 "kcode-k1-codex-adapter = \"0.5.3\"",
15 "kcode-k1-codex-websearch = \"0.2.0\"",
16 "kcode-k1-daemon-provider-config = \"0.1.6\"",
17 "kcode-k1-full-audio = \"0.3.7\"",
18 "kcode-k1-http-access-context = \"0.2.0\"",
19 "kcode-k1-http-access-profile-presentation = \"0.1.0\"",
20 "kcode-k1-http-audio = \"0.3.1\"",
21 "kcode-k1-http-audio-artifacts = \"0.4.0\"",
22 "kcode-k1-http-chat = \"0.7.2\"",
23 "kcode-k1-http-kmap = \"0.1.0\"",
24 "kcode-k1-http-launch-nodes = \"0.3.0\"",
25 "kcode-k1-http-people = \"0.9.0\"",
26 "kcode-k1-http-persons = \"0.3.0\"",
27 "kcode-k1-launch-nodes = \"0.4.0\"",
28 "kcode-k1-peering = \"0.3.0\"",
29 "kcode-k1-txn-ordering = \"0.5.1\"",
30];
31
32const OBSOLETE_LINES: &[&str] = &[
33 "kcode-k1-access = \"0.6.1\"",
34 "kcode-k1-access-full-audio = \"0.9.1\"",
35 "kcode-k1-access-launch-nodes = \"0.2.0\"",
36 "kcode-k1-audio-classification = \"0.5.9\"",
37 "kcode-k1-chat-service = \"0.3.0\"",
38 "kcode-k1-chat-service = \"0.6.0\"",
39 "kcode-k1-chat-service = \"0.7.0\"",
40 "kcode-k1-chat-service = \"0.8.0\"",
41 "kcode-k1-chat-service = \"0.9.0\"",
42 "kcode-k1-chat-service = \"0.10.0\"",
43 "kcode-k1-codex-adapter = \"0.5.0\"",
44 "kcode-k1-codex-adapter = \"0.5.1\"",
45 "kcode-k1-codex-websearch = \"0.1.0\"",
46 "kcode-k1-daemon-provider-config = \"0.1.4\"",
47 "kcode-k1-daemon-provider-config = \"0.1.5\"",
48 "kcode-k1-http-audio = \"0.3.0\"",
49 "kcode-k1-http-chat = \"0.2.0\"",
50 "kcode-k1-http-chat = \"0.5.0\"",
51 "kcode-k1-http-chat = \"0.6.0\"",
52 "kcode-k1-http-chat = \"0.6.1\"",
53 "kcode-k1-http-chat = \"0.7.0\"",
54 "kcode-k1-http-chat = \"0.7.1\"",
55 "kcode-k1-http-launch-nodes = \"0.2.0\"",
56 "kcode-k1-http-audio-artifacts = \"0.3.0\"",
57 "kcode-k1-launch-nodes = \"0.3.0\"",
58];
59
60pub fn verify_manifest(manifest: &str) {
61 for required in REQUIRED_LINES {
62 assert!(
63 manifest.lines().any(|line| line == *required),
64 "missing required manifest line: {required}"
65 );
66 }
67 for obsolete in OBSOLETE_LINES {
68 assert!(
69 !manifest.lines().any(|line| line == *obsolete),
70 "obsolete manifest line: {obsolete}"
71 );
72 }
73 assert!(
74 !manifest.lines().any(|line| line.contains(" = \"=")),
75 "manifest contains an exact internal pin"
76 );
77}
78
79#[cfg(test)]
80mod tests {
81 use super::*;
82
83 fn good_manifest() -> String {
84 REQUIRED_LINES.join("\n")
85 }
86
87 #[test]
88 fn accepts_current_manifest() {
89 verify_manifest(&good_manifest());
90 }
91
92 #[test]
93 #[should_panic(expected = "missing required manifest line")]
94 fn rejects_missing_required_line() {
95 verify_manifest(&good_manifest().replacen(
96 "kcode-k1-http-audio-artifacts = \"0.4.0\"\n",
97 "",
98 1,
99 ));
100 }
101
102 #[test]
103 #[should_panic(expected = "missing required manifest line")]
104 fn rejects_missing_http_chat_0_7_2() {
105 verify_manifest(&good_manifest().replacen("kcode-k1-http-chat = \"0.7.2\"\n", "", 1));
106 }
107
108 #[test]
109 #[should_panic(expected = "missing required manifest line")]
110 fn rejects_missing_http_kmap() {
111 verify_manifest(&good_manifest().replacen("kcode-k1-http-kmap = \"0.1.0\"\n", "", 1));
112 }
113
114 #[test]
115 #[should_panic(expected = "obsolete manifest line")]
116 fn rejects_displaced_access_launch_nodes() {
117 verify_manifest(&format!(
118 "{}\nkcode-k1-access-launch-nodes = \"0.2.0\"",
119 good_manifest()
120 ));
121 }
122
123 #[test]
124 #[should_panic(expected = "obsolete manifest line")]
125 fn rejects_displaced_launch_nodes() {
126 verify_manifest(&format!(
127 "{}\nkcode-k1-launch-nodes = \"0.3.0\"",
128 good_manifest()
129 ));
130 }
131
132 #[test]
133 #[should_panic(expected = "obsolete manifest line")]
134 fn rejects_obsolete_line() {
135 verify_manifest(&format!(
136 "{}\nkcode-k1-http-chat = \"0.7.1\"",
137 good_manifest()
138 ));
139 }
140
141 #[test]
142 #[should_panic(expected = "exact internal pin")]
143 fn rejects_exact_internal_pin() {
144 verify_manifest(&format!(
145 "{}\nkcode-k1-peering = \"=0.3.1\"",
146 good_manifest()
147 ));
148 }
149}