A lot more fixtures, use chrono for date.

This commit is contained in:
2019-01-22 10:27:38 +01:00
parent 94fa03d45c
commit 8e0563b463
44 changed files with 6493 additions and 17 deletions

View File

@@ -19,11 +19,15 @@ fn from_html(document: &str) -> Result<Entry, ()> {
messages.push(message);
}
Ok(Entry {
messages,
history,
comments,
})
if messages.is_empty() {
Err(())
} else {
Ok(Entry {
messages,
history,
comments,
})
}
}
pub struct KonsumentInfo;
@@ -59,8 +63,36 @@ impl Probe for KonsumentInfo {
#[cfg(test)]
mod tests {
use pretty_assertions::assert_eq;
use super::*;
#[test]
fn test_0104754350() {
let document = include_str!("../../fixtures/konsumentinfo/0104754350.html");
let expected = Entry {
messages: vec![],
history: vec![],
comments: vec![],
};
assert_eq!(from_html(&document), Ok(expected));
}
#[test]
fn test_0313908905() {
let document = include_str!("../../fixtures/konsumentinfo/0313908905.html");
let expected = Entry {
messages: vec![],
history: vec![],
comments: vec![],
};
assert_eq!(from_html(&document), Ok(expected));
}
#[test]
fn test_0702269893() {
let document = include_str!("../../fixtures/konsumentinfo/0702269893.html");
@@ -73,4 +105,56 @@ mod tests {
assert_eq!(from_html(&document), Ok(expected));
}
#[test]
fn test_0726443387() {
let document = include_str!("../../fixtures/konsumentinfo/0726443387.html");
let expected = Entry {
messages: vec![],
history: vec![],
comments: vec![],
};
assert_eq!(from_html(&document), Ok(expected));
}
#[test]
fn test_0751793426() {
let document = include_str!("../../fixtures/konsumentinfo/0751793426.html");
let expected = Entry {
messages: vec![],
history: vec![],
comments: vec![],
};
assert_eq!(from_html(&document), Ok(expected));
}
#[test]
fn test_0751793483() {
let document = include_str!("../../fixtures/konsumentinfo/0751793483.html");
let expected = Entry {
messages: vec![],
history: vec![],
comments: vec![],
};
assert_eq!(from_html(&document), Ok(expected));
}
#[test]
fn test_0751793499() {
let document = include_str!("../../fixtures/konsumentinfo/0751793499.html");
let expected = Entry {
messages: vec![],
history: vec![],
comments: vec![],
};
assert_eq!(from_html(&document), Ok(expected));
}
}