Unified · Split
| @@ -6,6 +6,30 @@ use std::collections::BTreeSet; · 5 unmodified lines | |||
| 6 | pub(crate) mod types; | 6 | pub(crate) mod types; |
| 7 | pub use types::{Item, Mapping, Outcome, Source}; | 7 | pub use types::{Item, Mapping, Outcome, Source}; |
| 8 | 8 | ||
| 9 | /// | ||
| 10 | pub mod validate { | ||
| 11 | use crate::match_group::Outcome; | ||
| 12 | |||
| 13 | /// All possible issues found while validating matched mappings. | ||
| 14 | #[derive(Debug)] | ||
| 15 | pub enum Issue {} | ||
| 16 | |||
| 17 | /// The error returned [outcome validation][Outcome::validated()]. | ||
| 18 | #[derive(Debug, thiserror::Error)] | ||
| 19 | #[error("TBD")] | ||
| 20 | pub struct Error { | ||
| 21 | /// All issues discovered during validation. | ||
| 22 | pub issues: Vec<Issue>, | ||
| 23 | } | ||
| 24 | |||
| 25 | impl<'spec, 'item> Outcome<'spec, 'item> { | ||
| 26 | /// Validate all mappings or dissolve them into an error stating the discovered issues. | ||
| 27 | pub fn validated(self) -> Result<Self, Error> { | ||
| 28 | Ok(self) | ||
| 29 | } | ||
| 30 | } | ||
| 31 | } | ||
| 32 | |||
| 9 | /// Initialization | 33 | /// Initialization |
| 10 | impl<'a> MatchGroup<'a> { | 34 | impl<'a> MatchGroup<'a> { |
| 11 | /// Take all the fetch ref specs from `specs` get a match group ready. | 35 | /// Take all the fetch ref specs from `specs` get a match group ready. |
| @@ -130,13 +130,16 @@ pub mod baseline { · 129 unmodified lines | |||
| 130 | .unwrap_or_else(|| panic!("BUG: Need {:?} added to the baseline", key)) | 130 | .unwrap_or_else(|| panic!("BUG: Need {:?} added to the baseline", key)) |
| 131 | .as_ref(); | 131 | .as_ref(); |
| 132 | 132 | ||
| 133 | let actual = match_group.match_remotes(input()).mappings; | 133 | let actual = match_group.match_remotes(input()).validated(); |
| 134 | let expected = match &mode { | 134 | let (actual, expected) = match &mode { |
| 135 | Mode::Normal { validate_err } => match validate_err { | 135 | Mode::Normal { validate_err } => match validate_err { |
| 136 | Some(_err_message) => todo!("validation and error comparison"), | 136 | Some(err_message) => { |
| 137 | None => expected.expect("no error"), | 137 | assert_eq!(actual.unwrap_err().to_string(), *err_message); |
| 138 | return; | ||
| 139 | } | ||
| 140 | None => (actual.unwrap().mappings, expected.expect("no error")), | ||
| 138 | }, | 141 | }, |
| 139 | Mode::Custom { expected } => expected, | 142 | Mode::Custom { expected } => (actual.unwrap().mappings, expected), |
| 140 | }; | 143 | }; |
| 141 | assert_eq!( | 144 | assert_eq!( |
| 142 | actual.len(), | 145 | actual.len(), |