2020-05-23 12:32:40 +00:00
|
|
|
use opml::*;
|
2021-03-22 11:41:11 +00:00
|
|
|
use std::fs::read_to_string as read;
|
2020-05-23 12:32:40 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
#[should_panic]
|
|
|
|
fn test_invalid_xml() {
|
2020-05-24 13:31:17 +00:00
|
|
|
let sample = read("tests/samples/invalid_xml.opml").unwrap();
|
|
|
|
OPML::new(sample.as_str()).unwrap();
|
2020-05-23 12:32:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_invalid_opml_version() {
|
2020-05-24 13:31:17 +00:00
|
|
|
let sample = read("tests/samples/invalid_opml_version.opml").unwrap();
|
2021-03-22 11:41:11 +00:00
|
|
|
let res = OPML::new(sample.as_str());
|
|
|
|
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() {
|
2020-05-24 13:31:17 +00:00
|
|
|
let sample = read("tests/samples/invalid_opml_no_outlines.opml").unwrap();
|
2021-03-22 11:41:11 +00:00
|
|
|
let res = OPML::new(sample.as_str());
|
|
|
|
assert!(matches!(res, Err(Error::BodyHasNoOutlines)));
|
2020-05-23 12:32:40 +00:00
|
|
|
}
|