Skip to content
Prev Previous commit
use unwrap to ensure both Ok, and remove test helper function
  • Loading branch information
katrinafyi committed Nov 10, 2025
commit 1525719af6604d00b0db6f86c794b3a9f2426594
14 changes: 4 additions & 10 deletions lychee-lib/src/types/input/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,24 +214,18 @@ impl Display for InputSource {
mod tests {
use super::*;

fn to_json<T>(value: &T) -> Result<String, String>
where
T: serde::Serialize + ?Sized,
{
serde_json::to_string(value).map_err(|e| e.to_string())
}

/// Serialization of `FsGlob` relies on [`glob::Pattern::to_string`].
/// Here, we check that the `to_string` works as we require.
#[test]
fn test_pattern_serialization_is_original_pattern() {
let pat = "asd[f]*";
assert_eq!(
to_json(&InputSource::FsGlob {
serde_json::to_string(&InputSource::FsGlob {
pattern: Pattern::new(pat).unwrap(),
ignore_case: false,
}),
to_json(pat),
})
.unwrap(),
serde_json::to_string(pat).unwrap(),
);
}
}