Skip to main content

kcode_k1_daemon_lib_testkit/
lib.rs

1#![doc = include_str!("../Documentation.md")]
2#![forbid(unsafe_code)]
3
4pub fn verify_manifest(manifest: &str) {
5    for required in [
6        "kcode-k1-daemon-http-composition = \"0.1.2\"",
7        "kcode-k1-daemon-provider-config = \"0.2.1\"",
8        "kcode-k1-text-inference = \"0.1.0\"",
9        "kcode-k1-daemon-lib-testkit = \"0.5.8\"",
10    ] {
11        assert!(manifest.contains(required), "daemon manifest selection");
12    }
13    for stale in [
14        "kcode-k1-daemon-http-composition = \"0.1.1\"",
15        "kcode-k1-daemon-provider-config = \"0.2.0\"",
16        "kcode-k1-daemon-lib-testkit = \"0.5.7\"",
17    ] {
18        assert!(!manifest.contains(stale), "stale daemon manifest selection");
19    }
20}
21
22pub fn verify_source(source: &str) {
23    for required in [
24        "text_inference_config(",
25        "CodexTextInference::new(",
26        "text_inference: text_inference as Arc<dyn TextInference>",
27        "kcode_k1_daemon_http_composition::prepare(",
28    ] {
29        assert!(
30            source.contains(required),
31            "daemon text-inference composition"
32        );
33    }
34}
35
36#[cfg(test)]
37mod tests {
38    use super::*;
39
40    #[test]
41    fn accepts_current_contract() {
42        verify_manifest(
43            "kcode-k1-daemon-http-composition = \"0.1.2\"\n\
44             kcode-k1-daemon-provider-config = \"0.2.1\"\n\
45             kcode-k1-text-inference = \"0.1.0\"\n\
46             kcode-k1-daemon-lib-testkit = \"0.5.8\"",
47        );
48        verify_source(
49            "text_inference_config( CodexTextInference::new( \
50             text_inference: text_inference as Arc<dyn TextInference> \
51             kcode_k1_daemon_http_composition::prepare(",
52        );
53    }
54}