From 62741cc682448f50aaaf5be198d6eeafda37c3d8 Mon Sep 17 00:00:00 2001 From: Dan Davison Date: Sat, 24 Apr 2021 07:04:53 -0400 Subject: Add failing tests for remote repo string parsing --- src/git_config/git_config_entry.rs | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) 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()) + ); + } +} -- cgit v1.2.3