mirror of
https://github.com/gitui-org/gitui
synced 2026-05-24 09:28:21 +00:00
unittest
This commit is contained in:
parent
db361a354f
commit
018e87c20a
1 changed files with 23 additions and 0 deletions
|
|
@ -93,6 +93,7 @@ mod tests {
|
||||||
use commit::amend;
|
use commit::amend;
|
||||||
use git2::Repository;
|
use git2::Repository;
|
||||||
use std::{fs::File, io::Write, path::Path};
|
use std::{fs::File, io::Write, path::Path};
|
||||||
|
use tempfile::TempDir;
|
||||||
|
|
||||||
fn count_commits(repo: &Repository, max: usize) -> usize {
|
fn count_commits(repo: &Repository, max: usize) -> usize {
|
||||||
let mut items = Vec::new();
|
let mut items = Vec::new();
|
||||||
|
|
@ -185,4 +186,26 @@ mod tests {
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_commit_unknown_signature() {
|
||||||
|
let file_path = Path::new("foo");
|
||||||
|
let td = TempDir::new().unwrap();
|
||||||
|
let repo = Repository::init(td.path()).unwrap();
|
||||||
|
let root = repo.path().parent().unwrap();
|
||||||
|
let repo_path = root.as_os_str().to_str().unwrap();
|
||||||
|
|
||||||
|
File::create(&root.join(file_path))
|
||||||
|
.unwrap()
|
||||||
|
.write_all(b"test\nfoo")
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
stage_add_file(repo_path, file_path).unwrap();
|
||||||
|
|
||||||
|
let id = commit(repo_path, "commit msg").unwrap();
|
||||||
|
|
||||||
|
let details = get_commit_details(repo_path, id).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(details.author.name, "unknown");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue