Skip to content

Commit

Permalink
add test for (#118)
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephan Dilly committed Jun 12, 2020
1 parent 7c0fe18 commit fdd84a8
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions asyncgit/src/sync/reset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ pub fn reset_workdir_file(repo_path: &str, path: &str) -> Result<()> {
let mut checkout_opts = CheckoutBuilder::new();
checkout_opts
.update_index(true) // windows: needs this to be true WTF?!
.allow_conflicts(true)
.force()
.path(path);

Expand All @@ -76,7 +75,6 @@ pub fn reset_workdir_folder(
let mut checkout_opts = CheckoutBuilder::new();
checkout_opts
.update_index(true) // windows: needs this to be true WTF?!
.allow_conflicts(true)
.remove_untracked(true)
.force()
.path(path);
Expand Down Expand Up @@ -334,4 +332,29 @@ mod tests {

assert_eq!(get_statuses(repo_path), (0, 0));
}

#[test]
fn test_reset_untracked_subdir() {
let (_td, repo) = repo_init().unwrap();
let root = repo.path().parent().unwrap();
let repo_path = root.as_os_str().to_str().unwrap();

{
fs::create_dir_all(&root.join("foo/bar")).unwrap();
File::create(&root.join("foo/bar/baz.txt"))
.unwrap()
.write_all(b"test\nfoo")
.unwrap();
}

debug_cmd_print(repo_path, "git status");

assert_eq!(get_statuses(repo_path), (1, 0));

reset_workdir_folder(repo_path, "foo/bar").unwrap();

debug_cmd_print(repo_path, "git status");

assert_eq!(get_statuses(repo_path), (0, 0));
}
}

0 comments on commit fdd84a8

Please sign in to comment.