Unverified Commit abbea2c0 authored by Alexandru Vasile's avatar Alexandru Vasile
Browse files

Remove `SubscriptionSinkState`"

parent 45cfdf08
......@@ -1166,65 +1166,3 @@ impl Drop for Subscription {
self.close();
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn sink_state_pending() {
let mut state = SubscriptionSinkState::new(Id::Number(0));
assert!(matches!(state, SubscriptionSinkState::Pending(Some(Id::Number(0)))));
assert!(matches!(state.id(), Ok(Id::Number(0))));
assert!(matches!(state, SubscriptionSinkState::Pending(None)));
assert!(matches!(state.id(), Err(SubscriptionEmptyError)));
}
#[test]
fn sink_state_accepted() {
let mut state = SubscriptionSinkState::new(Id::Number(0));
let (_, rx) = watch::channel(());
// Invalid transition without consuming the ID.
assert!(matches!(state.accept(rx.clone()), Err(SubscriptionEmptyError)));
assert!(matches!(state, SubscriptionSinkState::Pending(Some(Id::Number(0)))));
// Transition to accepted.
assert!(matches!(state.id(), Ok(Id::Number(0))));
let state = state.accept(rx.clone());
assert!(matches!(state, Ok(SubscriptionSinkState::Accepted(_))));
let mut state = state.unwrap();
// Double transition.
assert!(matches!(state.accept(rx.clone()), Err(SubscriptionEmptyError)));
// Invalid method call in this state.
assert!(matches!(state.id(), Err(SubscriptionEmptyError)));
// Invalid transition.
assert!(matches!(state.reject(), Err(SubscriptionEmptyError)));
}
#[test]
fn sink_state_rejected() {
let mut state = SubscriptionSinkState::new(Id::Number(0));
// Invalid transition without consuming the ID.
assert!(matches!(state.reject(), Err(SubscriptionEmptyError)));
assert!(matches!(state, SubscriptionSinkState::Pending(Some(Id::Number(0)))));
// Transition to rejected.
assert!(matches!(state.id(), Ok(Id::Number(0))));
let state = state.reject();
assert!(matches!(state, Ok(SubscriptionSinkState::Rejected)));
let mut state = state.unwrap();
// Double transition.
assert!(matches!(state.reject(), Err(SubscriptionEmptyError)));
// Invalid method call in this state.
assert!(matches!(state.id(), Err(SubscriptionEmptyError)));
// Invalid transition.
let (_, rx) = watch::channel(());
assert!(matches!(state.accept(rx), Err(SubscriptionEmptyError)));
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment