Skip to content
This repository was archived by the owner on Sep 23, 2025. It is now read-only.

Commit 39c5a01

Browse files
nikomatsakisClaude
andcommitted
Fix UUID determinism in tests by making UUID generation a service
- Add generate_uuid() method to IpcClient trait - MockIpcClient returns 'DUMMY_UUID' for deterministic tests - IPCCommunicator generates real UUIDs in production - Add user_data() getter to DialectInterpreter for accessing IpcClient - Update Comment function to use IpcClient for UUID generation - Update test expectation to use deterministic UUID All 36 tests now pass! 🎉 Co-authored-by: Claude <[email protected]>
1 parent f7a359d commit 39c5a01

File tree

4 files changed

+15
-2
lines changed

4 files changed

+15
-2
lines changed

server/src/dialect.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ impl<U: Send> DialectInterpreter<U> {
2626
}
2727
}
2828

29+
pub fn user_data(&self) -> &U {
30+
&self.userdata
31+
}
32+
2933
pub fn add_function<F>(&mut self)
3034
where
3135
F: DialectFunction<U>,

server/src/ide.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ mod test;
1212
pub trait IpcClient: Send {
1313
async fn resolve_symbol_by_name(&mut self, name: &str) -> anyhow::Result<Vec<SymbolDef>>;
1414
async fn find_all_references(&mut self, symbol: &SymbolDef) -> anyhow::Result<Vec<FileRange>>;
15+
fn generate_uuid(&self) -> String;
1516
}
1617

1718
/// The "symbols" file is used as the expected argument
@@ -355,7 +356,7 @@ impl<U: IpcClient> DialectFunction<U> for Comment {
355356
}
356357

357358
Ok(ResolvedComment {
358-
id: uuid::Uuid::new_v4().to_string(),
359+
id: interpreter.user_data().generate_uuid(),
359360
locations,
360361
icon: self.icon,
361362
comment: resolved_content,

server/src/ide/test.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ impl IpcClient for MockIpcClient {
100100
.cloned()
101101
.unwrap_or_default())
102102
}
103+
104+
fn generate_uuid(&self) -> String {
105+
"DUMMY_UUID".to_string()
106+
}
103107
}
104108

105109
// IDE Function Tests
@@ -700,7 +704,7 @@ async fn test_comment_function_with_symbol_def() {
700704
String("This function needs better error handling"),
701705
],
702706
"icon": String("warning"),
703-
"id": String("1a67e922-b26f-4175-93d8-a0d6d5c5598d"),
707+
"id": String("DUMMY_UUID"),
704708
"locations": Array [
705709
Object {
706710
"content": String("fn validateToken(token: &str) -> bool {"),

server/src/ipc.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,6 +1066,10 @@ impl crate::ide::IpcClient for IPCCommunicator {
10661066

10671067
Ok(locations)
10681068
}
1069+
1070+
fn generate_uuid(&self) -> String {
1071+
uuid::Uuid::new_v4().to_string()
1072+
}
10691073
}
10701074

10711075
#[cfg(test)]

0 commit comments

Comments
 (0)