From 3fb2a63b013a1ea11efbcd4cb514c1a32147f624 Mon Sep 17 00:00:00 2001 From: Micha Reiser Date: Thu, 11 Dec 2025 20:05:02 +0100 Subject: [PATCH] Add test --- crates/ty_ide/src/workspace_symbols.rs | 48 +++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/crates/ty_ide/src/workspace_symbols.rs b/crates/ty_ide/src/workspace_symbols.rs index f4af3df386..7e3929da70 100644 --- a/crates/ty_ide/src/workspace_symbols.rs +++ b/crates/ty_ide/src/workspace_symbols.rs @@ -64,7 +64,7 @@ mod tests { }; #[test] - fn test_workspace_symbols_multi_file() { + fn workspace_symbols_multi_file() { let test = CursorTest::builder() .source( "utils.py", @@ -126,6 +126,52 @@ API_BASE_URL = 'https://api.example.com' "); } + #[test] + fn members() { + let test = CursorTest::builder() + .source( + "utils.py", + " +class Test: + def from_path(): ... +", + ) + .build(); + + assert_snapshot!(test.workspace_symbols("from"), @r" + info[workspace-symbols]: WorkspaceSymbolInfo + --> utils.py:3:9 + | + 2 | class Test: + 3 | def from_path(): ... + | ^^^^^^^^^ + | + info: Method from_path + "); + + assert_snapshot!(test.workspace_symbols("data"), @r" + info[workspace-symbols]: WorkspaceSymbolInfo + --> models.py:2:7 + | + 2 | class DataModel: + | ^^^^^^^^^ + 3 | '''A data model class''' + 4 | def __init__(self): + | + info: Class DataModel + "); + + assert_snapshot!(test.workspace_symbols("apibase"), @r" + info[workspace-symbols]: WorkspaceSymbolInfo + --> constants.py:2:1 + | + 2 | API_BASE_URL = 'https://api.example.com' + | ^^^^^^^^^^^^ + | + info: Constant API_BASE_URL + "); + } + impl CursorTest { fn workspace_symbols(&self, query: &str) -> String { let symbols = workspace_symbols(&self.db, query);