diff --git a/src/pubsub/event.rs b/src/pubsub/event.rs index 8b990e4..14cec12 100644 --- a/src/pubsub/event.rs +++ b/src/pubsub/event.rs @@ -69,9 +69,6 @@ pub enum PubSubEvent { node: NodeName, redirect: Option, }, - EmptyItems { - node: NodeName, - }, PublishedItems { node: NodeName, items: Vec, @@ -119,9 +116,9 @@ fn parse_items(elem: Element, node: NodeName) -> Result { } } Ok(match is_retract { - None => PubSubEvent::EmptyItems { node }, Some(false) => PubSubEvent::PublishedItems { node, items }, Some(true) => PubSubEvent::RetractedItems { node, items: retracts }, + None => return Err(Error::ParseError("Missing children in items element.")), }) } @@ -204,12 +201,6 @@ impl From for Element { })) .build() }, - PubSubEvent::EmptyItems { node } => { - Element::builder("items") - .ns(ns::PUBSUB_EVENT) - .attr("node", node) - .build() - }, PubSubEvent::PublishedItems { node, items } => { Element::builder("items") .ns(ns::PUBSUB_EVENT) @@ -260,13 +251,14 @@ mod tests { use compare_elements::NamespaceAwareCompare; #[test] - fn test_simple() { + fn missing_items() { let elem: Element = "".parse().unwrap(); - let event = PubSubEvent::try_from(elem).unwrap(); - match event { - PubSubEvent::EmptyItems { node } => assert_eq!(node, NodeName(String::from("coucou"))), + let error = PubSubEvent::try_from(elem).unwrap_err(); + let message = match error { + Error::ParseError(string) => string, _ => panic!(), - } + }; + assert_eq!(message, "Missing children in items element."); } #[test]