diff --git a/src/disco.rs b/src/disco.rs index 3100d4b5..afb1fa7f 100644 --- a/src/disco.rs +++ b/src/disco.rs @@ -85,6 +85,8 @@ pub fn parse_disco(root: &Element) -> Result { } } + /* + // TODO: encode these restrictions only for result disco#info, not get ones. if identities.is_empty() { return Err(Error::ParseError("There must be at least one identity in disco#info.")); } @@ -94,6 +96,7 @@ pub fn parse_disco(root: &Element) -> Result { if !features.contains(&Feature { var: DISCO_INFO_NS.to_owned() }) { return Err(Error::ParseError("disco#info feature not present in disco#info.")); } + */ return Ok(Disco { node: node, @@ -128,15 +131,10 @@ mod tests { _ => panic!(), }; assert_eq!(message, "Unknown element in disco#info."); + } - let elem: Element = "".parse().unwrap(); - let error = disco::parse_disco(&elem).unwrap_err(); - let message = match error { - Error::ParseError(string) => string, - _ => panic!(), - }; - assert_eq!(message, "There must be at least one identity in disco#info."); - + #[test] + fn test_invalid_identity() { let elem: Element = "".parse().unwrap(); let error = disco::parse_disco(&elem).unwrap_err(); let message = match error { @@ -168,7 +166,10 @@ mod tests { _ => panic!(), }; assert_eq!(message, "Identity must have a non-empty 'type' attribute."); + } + #[test] + fn test_invalid_feature() { let elem: Element = "".parse().unwrap(); let error = disco::parse_disco(&elem).unwrap_err(); let message = match error { @@ -176,6 +177,18 @@ mod tests { _ => panic!(), }; assert_eq!(message, "Feature must have a 'var' attribute."); + } + + #[test] + #[ignore] + fn test_invalid_result() { + let elem: Element = "".parse().unwrap(); + let error = disco::parse_disco(&elem).unwrap_err(); + let message = match error { + Error::ParseError(string) => string, + _ => panic!(), + }; + assert_eq!(message, "There must be at least one identity in disco#info."); let elem: Element = "".parse().unwrap(); let error = disco::parse_disco(&elem).unwrap_err();