-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test repo, start refactoring app
- Loading branch information
Showing
5 changed files
with
92 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
[submodule "tests/repo"] | ||
path = tests/repo | ||
url = git@github.com:sondr3/git-anger-management-test-repo.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use git2::Repository; | ||
use git_anger_management::Repo; | ||
use std::path::{Path, PathBuf}; | ||
|
||
#[test] | ||
fn test_commit_count() { | ||
let repo = Repository::open(Path::new("./tests/repo").to_path_buf()).unwrap(); | ||
let commits = Repo::commits(&repo).unwrap(); | ||
assert_eq!(commits.len(), 4); | ||
} | ||
|
||
#[test] | ||
fn test_example_repo() { | ||
let repo = Repository::open(Path::new("./tests/repo").to_path_buf()).unwrap(); | ||
let commits = Repo::commits(&repo).unwrap(); | ||
let mut repo = Repo::new("repo"); | ||
repo.build(commits); | ||
|
||
assert_eq!(repo.authors.len(), 2); | ||
assert_eq!(repo.total_commits, 4); | ||
assert_eq!(repo.total_curses, 6); | ||
|
||
let john = repo.authors.get("John Doe").unwrap(); | ||
assert_eq!(john.total_curses, 2); | ||
assert_eq!(john.total_commits, 1); | ||
assert_eq!(john.curses.get("bloody").unwrap(), &1); | ||
assert_eq!(john.curses.get("damn").unwrap(), &1); | ||
|
||
let me = repo.authors.get("Sondre Nilsen").unwrap(); | ||
assert_eq!(me.total_curses, 3); | ||
assert_eq!(me.total_commits, 3); | ||
assert_eq!(me.curses.get("fuck").unwrap(), &1); | ||
assert_eq!(me.curses.get("fucking").unwrap(), &1); | ||
assert_eq!(me.curses.get("shitty").unwrap(), &1); | ||
} |