mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-02 21:03:11 +00:00
## Summary Reference: https://github.com/astral-sh/ruff/pull/19391#discussion_r2222780892
30 lines
812 B
Rust
30 lines
812 B
Rust
use anyhow::Result;
|
|
use lsp_types::notification::PublishDiagnostics;
|
|
use ruff_db::system::SystemPath;
|
|
use ty_server::ClientOptions;
|
|
|
|
use crate::TestServerBuilder;
|
|
|
|
#[test]
|
|
fn on_did_open() -> Result<()> {
|
|
let workspace_root = SystemPath::new("src");
|
|
let foo = SystemPath::new("src/foo.py");
|
|
let foo_content = "\
|
|
def foo() -> str:
|
|
return 42
|
|
";
|
|
|
|
let mut server = TestServerBuilder::new()?
|
|
.with_workspace(workspace_root, ClientOptions::default())?
|
|
.with_file(foo, foo_content)?
|
|
.enable_pull_diagnostics(false)
|
|
.build()?
|
|
.wait_until_workspaces_are_initialized()?;
|
|
|
|
server.open_text_document(foo, &foo_content, 1);
|
|
let diagnostics = server.await_notification::<PublishDiagnostics>()?;
|
|
|
|
insta::assert_debug_snapshot!(diagnostics);
|
|
|
|
Ok(())
|
|
}
|