-
Notifications
You must be signed in to change notification settings - Fork 2
Add new tests and prepared functions todo #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -188,6 +188,30 @@ impl StateMachine { | |||||||||||||||||||||||||||||||||||||
| Ok(neighbors) | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // TODO: Get all connected memories transitively via BFS | ||||||||||||||||||||||||||||||||||||||
| // pub fn get_connected_transitive(&self, id: MemoryId) -> Result<Vec<MemoryId>> | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // TODO: Check if path exists between two nodes | ||||||||||||||||||||||||||||||||||||||
| // pub fn has_path(&self, from: MemoryId, to: MemoryId) -> bool | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // TODO: Delete all memories in a collection | ||||||||||||||||||||||||||||||||||||||
| // pub fn delete_collection(&mut self, collection: &str) -> Result<()> | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // TODO: Get all unique collection names | ||||||||||||||||||||||||||||||||||||||
| // pub fn collections(&self) -> Vec<String> | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // TODO: Get count of memories in a collection | ||||||||||||||||||||||||||||||||||||||
| // pub fn collection_len(&self, collection: &str) -> usize | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // TODO: Get N most recent memories | ||||||||||||||||||||||||||||||||||||||
| // pub fn get_latest(&self, n: usize) -> Vec<&MemoryEntry> | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // TODO: Get N oldest memories | ||||||||||||||||||||||||||||||||||||||
| // pub fn get_oldest(&self, n: usize) -> Vec<&MemoryEntry> | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| // TODO: Add multiple entries in bulk | ||||||||||||||||||||||||||||||||||||||
| // pub fn add_many(&mut self, entries: Vec<MemoryEntry>) -> Result<()> | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| /// Get size of state | ||||||||||||||||||||||||||||||||||||||
| pub fn len(&self) -> usize { | ||||||||||||||||||||||||||||||||||||||
| self.memories.len() | ||||||||||||||||||||||||||||||||||||||
|
|
@@ -386,4 +410,149 @@ mod tests { | |||||||||||||||||||||||||||||||||||||
| let result = sm.connect(MemoryId(1), MemoryId(2), "bad".to_string()); | ||||||||||||||||||||||||||||||||||||||
| assert!(matches!(result, Err(StateMachineError::CrossCollectionEdge { .. }))); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| #[test] | ||||||||||||||||||||||||||||||||||||||
| fn test_disconnect_nonexistent_edge() { | ||||||||||||||||||||||||||||||||||||||
| let mut sm = StateMachine::new(); | ||||||||||||||||||||||||||||||||||||||
| sm.add(create_test_entry(1, "default", 1000)).unwrap(); | ||||||||||||||||||||||||||||||||||||||
| sm.add(create_test_entry(2, "default", 1000)).unwrap(); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| sm.disconnect(MemoryId(1), MemoryId(2)).unwrap(); | ||||||||||||||||||||||||||||||||||||||
| sm.disconnect(MemoryId(1), MemoryId(2)).unwrap(); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| let neighbors = sm.get_neighbors(MemoryId(1)).unwrap(); | ||||||||||||||||||||||||||||||||||||||
| assert!(neighbors.is_empty()); | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| #[test] | ||||||||||||||||||||||||||||||||||||||
| fn test_disconnect_from_nonexistent_memory() { | ||||||||||||||||||||||||||||||||||||||
| let mut sm = StateMachine::new(); | ||||||||||||||||||||||||||||||||||||||
| sm.add(create_test_entry(1, "default", 1000)).unwrap(); | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| sm.disconnect(MemoryId(999), MemoryId(1)).unwrap(); | ||||||||||||||||||||||||||||||||||||||
| assert_eq!(sm.len(), 1); | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+428
to
+433
|
||||||||||||||||||||||||||||||||||||||
| fn test_disconnect_from_nonexistent_memory() { | |
| let mut sm = StateMachine::new(); | |
| sm.add(create_test_entry(1, "default", 1000)).unwrap(); | |
| sm.disconnect(MemoryId(999), MemoryId(1)).unwrap(); | |
| assert_eq!(sm.len(), 1); | |
| fn test_disconnect_is_idempotent_even_when_endpoint_memories_are_missing() { | |
| let mut sm = StateMachine::new(); | |
| sm.add(create_test_entry(1, "default", 1000)).unwrap(); | |
| // `disconnect` is intentionally a no-op when either endpoint is missing: | |
| // the postcondition is simply that the edge does not exist. | |
| sm.disconnect(MemoryId(999), MemoryId(1)).unwrap(); | |
| sm.disconnect(MemoryId(1), MemoryId(999)).unwrap(); | |
| assert_eq!(sm.len(), 1); | |
| let neighbors = sm.get_neighbors(MemoryId(1)).unwrap(); | |
| assert!(neighbors.is_empty()); |
Copilot
AI
Apr 21, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test name is misleading: the second connect call is expected to succeed (it’s unwrapped) and the behavior under test is edge de-duplication, not rejection via an error. Rename the test (and/or assert the exact behavior you want, e.g., that the second call returns Ok and does not increase neighbor count).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These commented-out function “signatures” inside the impl can easily drift out of sync and aren’t valid Rust declarations if someone tries to “uncomment” them later (impl fns require bodies). Consider moving this backlog to an issue/tracking doc, or add real stub methods with a minimal body (e.g., returning an error / todo!) behind an explicit feature flag so the compiler keeps signatures honest.