diff options
author | Dan Davison <dandavison7@gmail.com> | 2021-04-24 07:04:53 -0400 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2021-04-24 07:04:53 -0400 |
commit | 62741cc682448f50aaaf5be198d6eeafda37c3d8 (patch) | |
tree | c4b0d536a3a42587a0142418147ac0179b5d137b | |
parent | 86479d420f014fa63c717d8854fca33d5d6b6361 (diff) |
Add failing tests for remote repo string parsing
-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()) + ); + } +} |