Uncomment lsp2 tests

This commit is contained in:
Julia 2023-11-02 11:42:48 -04:00
parent ec0cff0e1a
commit b7efab8a55

View file

@ -1107,74 +1107,74 @@ impl FakeLanguageServer {
} }
} }
// #[cfg(test)] #[cfg(test)]
// mod tests { mod tests {
// use super::*; use super::*;
// use gpui::TestAppContext; use gpui2::TestAppContext;
// #[ctor::ctor] #[ctor::ctor]
// fn init_logger() { fn init_logger() {
// if std::env::var("RUST_LOG").is_ok() { if std::env::var("RUST_LOG").is_ok() {
// env_logger::init(); env_logger::init();
// } }
// } }
// #[gpui::test] #[gpui2::test]
// async fn test_fake(cx: &mut TestAppContext) { async fn test_fake(cx: &mut TestAppContext) {
// let (server, mut fake) = let (server, mut fake) =
// LanguageServer::fake("the-lsp".to_string(), Default::default(), cx.to_async()); LanguageServer::fake("the-lsp".to_string(), Default::default(), cx.to_async());
// let (message_tx, message_rx) = channel::unbounded(); let (message_tx, message_rx) = channel::unbounded();
// let (diagnostics_tx, diagnostics_rx) = channel::unbounded(); let (diagnostics_tx, diagnostics_rx) = channel::unbounded();
// server server
// .on_notification::<notification::ShowMessage, _>(move |params, _| { .on_notification::<notification::ShowMessage, _>(move |params, _| {
// message_tx.try_send(params).unwrap() message_tx.try_send(params).unwrap()
// }) })
// .detach(); .detach();
// server server
// .on_notification::<notification::PublishDiagnostics, _>(move |params, _| { .on_notification::<notification::PublishDiagnostics, _>(move |params, _| {
// diagnostics_tx.try_send(params).unwrap() diagnostics_tx.try_send(params).unwrap()
// }) })
// .detach(); .detach();
// let server = server.initialize(None).await.unwrap(); let server = server.initialize(None).await.unwrap();
// server server
// .notify::<notification::DidOpenTextDocument>(DidOpenTextDocumentParams { .notify::<notification::DidOpenTextDocument>(DidOpenTextDocumentParams {
// text_document: TextDocumentItem::new( text_document: TextDocumentItem::new(
// Url::from_str("file://a/b").unwrap(), Url::from_str("file://a/b").unwrap(),
// "rust".to_string(), "rust".to_string(),
// 0, 0,
// "".to_string(), "".to_string(),
// ), ),
// }) })
// .unwrap(); .unwrap();
// assert_eq!( assert_eq!(
// fake.receive_notification::<notification::DidOpenTextDocument>() fake.receive_notification::<notification::DidOpenTextDocument>()
// .await .await
// .text_document .text_document
// .uri .uri
// .as_str(), .as_str(),
// "file://a/b" "file://a/b"
// ); );
// fake.notify::<notification::ShowMessage>(ShowMessageParams { fake.notify::<notification::ShowMessage>(ShowMessageParams {
// typ: MessageType::ERROR, typ: MessageType::ERROR,
// message: "ok".to_string(), message: "ok".to_string(),
// }); });
// fake.notify::<notification::PublishDiagnostics>(PublishDiagnosticsParams { fake.notify::<notification::PublishDiagnostics>(PublishDiagnosticsParams {
// uri: Url::from_str("file://b/c").unwrap(), uri: Url::from_str("file://b/c").unwrap(),
// version: Some(5), version: Some(5),
// diagnostics: vec![], diagnostics: vec![],
// }); });
// assert_eq!(message_rx.recv().await.unwrap().message, "ok"); assert_eq!(message_rx.recv().await.unwrap().message, "ok");
// assert_eq!( assert_eq!(
// diagnostics_rx.recv().await.unwrap().uri.as_str(), diagnostics_rx.recv().await.unwrap().uri.as_str(),
// "file://b/c" "file://b/c"
// ); );
// fake.handle_request::<request::Shutdown, _, _>(|_, _| async move { Ok(()) }); fake.handle_request::<request::Shutdown, _, _>(|_, _| async move { Ok(()) });
// drop(server); drop(server);
// fake.receive_notification::<notification::Exit>().await; fake.receive_notification::<notification::Exit>().await;
// } }
// } }