Skip to content

Commit

Permalink
assert_matches
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyagr committed Mar 21, 2024
1 parent 5267cda commit d7c058e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ tracing-subscriber = "0.3.18"
walkdir = "2.4.0"

[dev-dependencies]
assert_matches = "1.5.0"
indoc = "2.0.4"
insta = { version = "1.34.0", features = [
"redactions",
Expand Down
22 changes: 10 additions & 12 deletions src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,9 @@ fn scan_several(roots: [&PathBuf; 3]) -> Result<EntriesToCompare, DataReadError>

#[cfg(test)]
mod tests {
use std::io::ErrorKind;

use assert_matches::assert_matches;
use indexmap::IndexMap;
use indoc::indoc;
use itertools::Itertools;
Expand Down Expand Up @@ -191,6 +194,7 @@ mod tests {
- type: Text
value: "Some text\n"
"###);
// TODO: A different bug if edit/subdir/another_file is specified
let mut input = left_right_edit_threedirinput(tmp_dir.path());
insta::assert_yaml_snapshot!(input.scan().unwrap(), @r###"
---
Expand All @@ -201,18 +205,12 @@ mod tests {
- type: Missing
"###);
let result = input.save(IndexMap::from([string_pair("subdir/txt", "")]));
insta::assert_debug_snapshot!(result, @r###"
Err(
IOError(
"/var/folders/lj/rv4h95_d0mxb9ryztzpz4qph0000gn/T/de3test.hg2lQoslcgCd/edit/subdir/txt",
Os {
code: 2,
kind: NotFound,
message: "No such file or directory",
},
),
)
"###);
// BUG
assert_matches!(result,
Err(DataSaveError::IOError(path, err))
if path.ends_with("subdir/txt") &&
err.kind() == ErrorKind::NotFound
);
let result = input.save(IndexMap::from([
string_pair("subdir/txt", ""),
string_pair("another_txt", ""),
Expand Down

0 comments on commit d7c058e

Please sign in to comment.