A lot more fixtures, use chrono for date.
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user