Skip to content

Commit 8a57155

Browse files
authored
Add test for gix_repo respecting workdir (#2790)
1 parent 37d3dd2 commit 8a57155

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

asyncgit/src/sync/status.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,50 @@ pub fn get_status(
280280

281281
Ok(res)
282282
}
283+
284+
#[cfg(test)]
285+
mod tests {
286+
use std::{fs::File, io::Write, path::Path};
287+
288+
use tempfile::TempDir;
289+
290+
use crate::{
291+
sync::{
292+
status::{get_status, StatusType},
293+
tests::repo_init_bare,
294+
RepoPath,
295+
},
296+
StatusItem, StatusItemType,
297+
};
298+
299+
#[test]
300+
#[should_panic]
301+
fn test_get_status_with_workdir() {
302+
let (git_dir, _repo) = repo_init_bare().unwrap();
303+
304+
let separate_workdir = TempDir::new().unwrap();
305+
306+
let file_path = Path::new("foo");
307+
File::create(separate_workdir.path().join(file_path))
308+
.unwrap()
309+
.write_all(b"a")
310+
.unwrap();
311+
312+
let repo_path = RepoPath::Workdir {
313+
gitdir: git_dir.path().into(),
314+
workdir: separate_workdir.path().into(),
315+
};
316+
317+
let status =
318+
get_status(&repo_path, StatusType::WorkingDir, None)
319+
.unwrap();
320+
321+
assert_eq!(
322+
status,
323+
vec![StatusItem {
324+
path: "foo".into(),
325+
status: StatusItemType::New
326+
}]
327+
);
328+
}
329+
}

0 commit comments

Comments
 (0)