services: imports: refine tests in allianzdirectcall.rs
Signed-off-by: Ralf Zerres <ralf.zerres@networkx.de>
This commit is contained in:
@@ -90,10 +90,37 @@ pub fn import(p: &mut String, data_list: &mut PolicyDataList,
|
|||||||
.expect("Clock may have gone backwards");
|
.expect("Clock may have gone backwards");
|
||||||
trace!(target: "advotrackerd", record_count = ?count, duration = ?duration);
|
trace!(target: "advotrackerd", record_count = ?count, duration = ?duration);
|
||||||
|
|
||||||
// Tests
|
state = t!("state.finished", lang);
|
||||||
|
res = t!("csv.import.finished", lang);
|
||||||
|
let datetime: DateTime<Local> = time_end.into();
|
||||||
|
trace!(target: "advotrackerd", process = ?res, state = ?state, date_stop = ?datetime.to_string());
|
||||||
|
|
||||||
|
Ok((count, duration))
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_import() {
|
||||||
// Takes a reference and returns Option<&V>
|
// Takes a reference and returns Option<&V>
|
||||||
let my_policy_numbers : [usize; 2] = [1511111111, 9999999993];
|
let my_policy_numbers : [usize; 2] = [1511111111, 9999999993];
|
||||||
assert_eq!(my_policy_numbers, [1511111111, 9999999993]);
|
assert_eq!(my_policy_numbers, [1511111111, 9999999993]);
|
||||||
|
|
||||||
|
let mut csv_import_path = String::from("data/POLLFNR_TEST.txt");
|
||||||
|
let mut policy_data = PolicyDataList::new("PolicyDataList");
|
||||||
|
let mut policy_numbers : HashMap<usize, PolicyCode> = HashMap::new();
|
||||||
|
let mut policy_data_count: usize = 0;
|
||||||
|
let lang = "en".to_string();
|
||||||
|
|
||||||
|
match import(&mut csv_import_path, &mut policy_data,
|
||||||
|
&mut policy_numbers, &mut policy_data_count,
|
||||||
|
&lang) {
|
||||||
|
Ok((count, duration)) => {
|
||||||
|
println!("import {:?} records. Duration: {:?}", count, duration);
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
println!("error running CSV-Import: {}", err);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
for p in &my_policy_numbers {
|
for p in &my_policy_numbers {
|
||||||
match policy_numbers.get(&p) {
|
match policy_numbers.get(&p) {
|
||||||
Some(policy_code) => {
|
Some(policy_code) => {
|
||||||
@@ -103,11 +130,4 @@ pub fn import(p: &mut String, data_list: &mut PolicyDataList,
|
|||||||
_ => println!("Test: Policy-Number {:?} => not valid, can't dereference the Policy-Type as expected", p),
|
_ => println!("Test: Policy-Number {:?} => not valid, can't dereference the Policy-Type as expected", p),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
state = t!("state.finished", lang);
|
|
||||||
res = t!("csv.import.finished", lang);
|
|
||||||
let datetime: DateTime<Local> = time_end.into();
|
|
||||||
trace!(target: "advotrackerd", process = ?res, state = ?state, date_stop = ?datetime.to_string());
|
|
||||||
|
|
||||||
Ok((count, duration))
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user