diff --git a/src/model/markers/found.rs b/src/model/markers/found.rs index db4b26a..051c5ca 100644 --- a/src/model/markers/found.rs +++ b/src/model/markers/found.rs @@ -13,7 +13,9 @@ impl FoundMarkers { impl std::fmt::Display for FoundMarkers { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { for marker in self.markers.iter() { - write!(f, "- {marker}")?; + // if !matches!(marker, Marker::Unmarked) { + write!(f, "{marker}")?; + // } } Ok(()) } diff --git a/src/model/markers/marker.rs b/src/model/markers/marker.rs index e411dfc..7c04856 100644 --- a/src/model/markers/marker.rs +++ b/src/model/markers/marker.rs @@ -13,8 +13,8 @@ impl std::fmt::Display for Marker { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Marker::Unmarked => Ok(()), - Marker::Invalid(line) => write!(f, "Invalid: {line}"), - Marker::Valid(line, _) => write!(f, "Valid : {line}"), + Marker::Invalid(line) => write!(f, "- Invalid: {line}"), + Marker::Valid(line, _) => write!(f, "- Valid : {line}"), } } } diff --git a/src/model/markers/mod.rs b/src/model/markers/mod.rs index c6f6f0b..ad11a0a 100644 --- a/src/model/markers/mod.rs +++ b/src/model/markers/mod.rs @@ -3,5 +3,8 @@ mod found; mod issue; mod marker; +#[cfg(test)] +mod tests; + pub use found::FoundMarkers; pub use marker::Marker; diff --git a/src/model/markers/tests/found.rs b/src/model/markers/tests/found.rs new file mode 100644 index 0000000..49f5dc9 --- /dev/null +++ b/src/model/markers/tests/found.rs @@ -0,0 +1,57 @@ +use crate::model::Line; + +// +use super::*; + +#[test] +fn found_when_displayed() -> anyhow::Result<()> { + //given + let fs = kxio::fs::temp()?; + let file = fs.base().join("file-name"); + let relative = file.strip_prefix(fs.base())?.to_path_buf(); + + let mut found = FoundMarkers::default(); + + let marker_unmarked = Line::builder() + .file(file.clone()) + .relative_path(relative.clone()) + .num(10) + .value("line with no comment".to_owned()) + .build() + .into_marker()?; + let marker_invalid = Line::builder() + .file(file.clone()) + .relative_path(relative.clone()) + .num(10) + .value("line // TODO: comment".to_owned()) + .build() + .into_marker()?; + let marker_valid = Line::builder() + .file(file) + .relative_path(relative) + .num(11) + .value("line // TODO: (#13) do this".to_owned()) + .build() + .into_marker()?; + + found.add_marker(marker_unmarked); + found.add_marker(marker_invalid); + found.add_marker(marker_valid); + + //when + let markers_as_string = found.to_string(); + let result = markers_as_string.lines().collect::>(); + + //then + assert_eq!( + result, + vec![ + "- Invalid: file-name#10:", + " line // TODO: comment", + "- Valid : file-name#11:", + " line // TODO: (#13) do this" + ] + ); + + Ok(()) +} diff --git a/src/model/markers/tests/issue.rs b/src/model/markers/tests/issue.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/model/markers/tests/marker.rs b/src/model/markers/tests/marker.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/model/markers/tests/mod.rs b/src/model/markers/tests/mod.rs new file mode 100644 index 0000000..998aef3 --- /dev/null +++ b/src/model/markers/tests/mod.rs @@ -0,0 +1,6 @@ +// +use super::*; + +mod found; +mod issue; +mod marker;