Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

Add basic test for labeled tasks

Kay Simmons6b6e4e3bfe77
diff --git a/crates/gpui/src/app.rs b/crates/gpui/src/app.rs
index 6c1eeef93c9..6e9090db59c 100644
--- a/crates/gpui/src/app.rs
+++ b/crates/gpui/src/app.rs
@@ -5279,6 +5279,7 @@ impl Subscription {
mod tests {
use super::*;
use crate::{actions, elements::*, impl_actions, MouseButton, MouseButtonEvent};
+ use postage::{sink::Sink, stream::Stream};
use serde::Deserialize;
use smol::future::poll_once;
use std::{
@@ -6894,6 +6895,23 @@ mod tests {
assert_eq!(presenter.borrow().rendered_views.len(), 1);
}
+ #[crate::test(self)]
+ async fn test_labeled_tasks(cx: &mut TestAppContext) {
+ assert_eq!(None, cx.update(|cx| cx.active_labeled_tasks().next()));
+ let (mut sender, mut reciever) = postage::oneshot::channel::<()>();
+ let task = cx
+ .update(|cx| cx.spawn_labeled("Test Label", |_| async move { reciever.recv().await }));
+
+ assert_eq!(
+ Some("Test Label"),
+ cx.update(|cx| cx.active_labeled_tasks().next())
+ );
+ sender.send(()).await;
+ task.await;
+
+ assert_eq!(None, cx.update(|cx| cx.active_labeled_tasks().next()));
+ }
+
#[crate::test(self)]
async fn test_window_activation(cx: &mut TestAppContext) {
struct View(&'static str);