opml/opml_api/tests/errors.rs

25 lines
654 B
Rust
Raw Permalink Normal View History

use std::fs::read_to_string as read;
2020-05-23 12:32:40 +00:00
2021-03-23 12:02:16 +00:00
use opml::*;
2020-05-23 12:32:40 +00:00
#[test]
#[should_panic]
fn test_invalid_xml() {
let sample = read("tests/samples/invalid_xml.opml").unwrap();
2021-03-23 12:02:16 +00:00
OPML::from_str(&sample).unwrap();
2020-05-23 12:32:40 +00:00
}
#[test]
fn test_invalid_opml_version() {
let sample = read("tests/samples/invalid_opml_version.opml").unwrap();
2021-03-23 12:02:16 +00:00
let res = OPML::from_str(&sample);
assert!(matches!(res, Err(Error::UnsupportedVersion(e)) if e == "invalid"));
2020-05-23 12:32:40 +00:00
}
#[test]
fn test_invalid_opml_no_outlines() {
let sample = read("tests/samples/invalid_opml_no_outlines.opml").unwrap();
2021-03-23 12:02:16 +00:00
let res = OPML::from_str(&sample);
assert!(matches!(res, Err(Error::BodyHasNoOutlines)));
2020-05-23 12:32:40 +00:00
}