mirror of https://github.com/astral-sh/ruff
Add test
This commit is contained in:
parent
9289e2e107
commit
3fb2a63b01
|
|
@ -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(): ...
|
||||
<CURSOR>",
|
||||
)
|
||||
.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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue