forked from 1jehuang/jcode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemory_agent_tests.rs
More file actions
51 lines (45 loc) · 1.36 KB
/
memory_agent_tests.rs
File metadata and controls
51 lines (45 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
use super::*;
use crate::memory::MemoryCategory;
#[test]
fn infer_candidate_tag_uses_repeated_non_stopword() {
let tag =
infer_candidate_tag("scheduler retries failed jobs and scheduler metrics update dashboard");
assert_eq!(tag.as_deref(), Some("scheduler"));
}
#[test]
fn apply_cluster_assignment_links_members() {
let mut graph = MemoryGraph::new();
let mut a = MemoryEntry::new(MemoryCategory::Fact, "A");
a.embedding = Some(vec![1.0, 0.0]);
let id_a = graph.add_memory(a);
let mut b = MemoryEntry::new(MemoryCategory::Fact, "B");
b.embedding = Some(vec![0.0, 1.0]);
let id_b = graph.add_memory(b);
let stats = apply_cluster_assignment(
&mut graph,
"project",
&[id_a.clone(), id_b.clone()],
Utc::now(),
);
assert_eq!(stats.clusters_touched, 1);
assert_eq!(stats.member_links, 2);
assert_eq!(graph.clusters.len(), 1);
let cluster_id = graph
.clusters
.keys()
.next()
.expect("cluster id")
.to_string();
assert!(
graph
.get_edges(&id_a)
.iter()
.any(|e| e.target == cluster_id && matches!(e.kind, EdgeKind::InCluster))
);
assert!(
graph
.get_edges(&id_b)
.iter()
.any(|e| e.target == cluster_id && matches!(e.kind, EdgeKind::InCluster))
);
}