diff options
-rw-r--r-- | src/git_config/git_config_entry.rs | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/src/git_config/git_config_entry.rs b/src/git_config/git_config_entry.rs index 4b0d80a3..bee64149 100644 --- a/src/git_config/git_config_entry.rs +++ b/src/git_config/git_config_entry.rs @@ -14,7 +14,7 @@ pub enum GitConfigEntry { Path(PathBuf), } -#[derive(Clone, Debug)] +#[derive(Clone, Debug, PartialEq)] pub enum GitRemoteRepo { GitHubRepo(String), } @@ -37,3 +37,28 @@ impl FromStr for GitRemoteRepo { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn test_parse_github_url_with_dot_git_suffix() { + let parsed = GitRemoteRepo::from_str("git@github.com:dandavison/delta.git"); + assert!(parsed.is_ok()); + assert_eq!( + parsed.unwrap(), + GitRemoteRepo::GitHubRepo("dandavison/delta".to_string()) + ); + } + + #[test] + fn test_parse_github_url_without_dot_git_suffix() { + let parsed = GitRemoteRepo::from_str("git@github.com:dandavison/delta"); + assert!(parsed.is_ok()); + assert_eq!( + parsed.unwrap(), + GitRemoteRepo::GitHubRepo("dandavison/delta".to_string()) + ); + } +} |