Skip to content

Commit

Permalink
add an assertion that handlers unregister immediately on error: closes
Browse files Browse the repository at this point in the history
  • Loading branch information
cablehead committed Dec 5, 2024
1 parent aedee58 commit fb1a8b3
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/handlers/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,15 @@ async fn test_unregister_on_error() {
let mut recver = store.read(options).await;
assert_eq!(recver.recv().await.unwrap().topic, "xs.threshold");

// This frame will trigger the error when the handler comes online
let frame_trigger = store.append(Frame::with_topic("trigger").build()).await;
validate_frame!(recver.recv().await.unwrap(), {topic: "trigger"});

// add an additional frame, which shouldn't be processed, as the handler should immediately
// unregister
let _ = store.append(Frame::with_topic("trigger").build()).await;
validate_frame!(recver.recv().await.unwrap(), {topic: "trigger"});

// Start handler
let frame_handler = store
.append(
Expand All @@ -311,16 +320,15 @@ async fn test_unregister_on_error() {
.await
.unwrap(),
)
.meta(serde_json::json!({
"start": {"cursor": "root"}
}))
.build(),
)
.await;
assert_eq!(recver.recv().await.unwrap().topic, "error.register");
assert_eq!(recver.recv().await.unwrap().topic, "error.registered");

// Trigger error
let frame_trigger = store.append(Frame::with_topic("trigger").build()).await;
validate_frame!( recver.recv().await.unwrap(), {topic: "trigger"});

// Expect an unregistered frame to be appended
validate_frame!(recver.recv().await.unwrap(), {
topic: "error.unregistered",
Expand Down

0 comments on commit fb1a8b3

Please sign in to comment.