RpcClient: subscribe and wait_for #6
Labels
No labels
area:assertions
area:cli
area:client
area:harness
area:meta
area:reporting
area:runner
type:user-story
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/ws-rpc-test#6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
User story
As a test author, I want to subscribe to specific event types and block until a matching one arrives, so that I can assert on async server behaviour without polling loops.
Acceptance criteria
subscribe
subscribe(events: &[&str]) -> Result<(), TestError>sends a JSON-RPC request: and awaits success.{"events":[]}.subscribeexplicitly to receive any events.wait_for
wait_for(method: &str, predicate: F, timeout: Duration) -> Result<Value, TestError>whereF: Fn(&Value) -> bool + Send + Sync.methodmatches and wherepredicate(¶ms)is true. Matching notifications are removed from the buffer so they aren't re-matched by a later call.paramsfield asValue.TestError::Timeout { event: method.into(), duration }.wait_forcalls from different tasks are safe: a notification matched by waiter A is not delivered to waiter B (first matching waiter wins).Out of scope
wait_for_any,collect_events,call_and_wait— separate issue.References