Skip to content

Commit

Permalink
Merge pull request #777 from CanalTP/log_vj_with_inconsistent_schedules
Browse files Browse the repository at this point in the history
  • Loading branch information
patochectp authored May 5, 2021
2 parents b48462b + 366b08e commit 80e5ae4
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/ntfs/read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ where
collections.stop_time_ids = stop_time_ids;
let mut vehicle_journeys = collections.vehicle_journeys.take();
for vj in &mut vehicle_journeys {
vj.sort_and_check_stop_times()?;
skip_error_and_log!(vj.sort_and_check_stop_times(), LogLevel::Error);
}
collections.vehicle_journeys = CollectionWithId::new(vehicle_journeys)?;
Ok(())
Expand Down Expand Up @@ -892,7 +892,6 @@ mod tests {
});
}
#[test]
#[should_panic(expected = "DuplicateStopSequence { vj_id: \"1\", duplicated_sequence: 3 }")]
fn stop_sequence_growing() {
test_in_tmp_dir(|path| {
let _ = generate_minimal_ntfs(path);
Expand All @@ -904,13 +903,21 @@ mod tests {
5,1,06:09:27,06:06:27,sp:05,3,2,1,,";
create_file_with_content(path, "stop_times.txt", stop_times_content);

let _collections = make_collection(path);
testing_logger::setup();
make_collection(path);
testing_logger::validate(|captured_logs| {
let error_log = captured_logs
.iter()
.find(|captured_log| captured_log.level == LogLevel::Error)
.expect("log error expected");
assert_eq!(
error_log.body,
"duplicate stop_sequence \'3\' for the trip \'1\'"
);
});
});
}
#[test]
#[should_panic(
expected = "IncoherentStopTimes { vj_id: \"1\", first_incorrect_sequence: 2, first_incorrect_time: Time(21987) }"
)]
fn stop_times_growing() {
test_in_tmp_dir(|path| {
let _ = generate_minimal_ntfs(path);
Expand All @@ -922,7 +929,18 @@ mod tests {
5,1,06:06:27,06:06:27,sp:05,5,2,1,,";
create_file_with_content(path, "stop_times.txt", stop_times_content);

testing_logger::setup();
make_collection(path);
testing_logger::validate(|captured_logs| {
let error_log = captured_logs
.iter()
.find(|captured_log| captured_log.level == LogLevel::Error)
.expect("log error expected");
assert_eq!(
error_log.body,
"incoherent stop times \'2\' at time \'06:06:27\' for the trip \'1\'"
);
});
});
}
}

0 comments on commit 80e5ae4

Please sign in to comment.