mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-12-03 22:59:46 +02:00
refactor to use regex for matching git service URL
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
// TestGetRepoInfoFromURL is a function.
|
||||
func TestGetRepoInfoFromURL(t *testing.T) {
|
||||
type scenario struct {
|
||||
service *Service
|
||||
testName string
|
||||
repoURL string
|
||||
test func(*RepoInformation)
|
||||
@@ -16,6 +17,7 @@ func TestGetRepoInfoFromURL(t *testing.T) {
|
||||
|
||||
scenarios := []scenario{
|
||||
{
|
||||
NewGithubService("github.com", "github.com"),
|
||||
"Returns repository information for git remote url",
|
||||
"git@github.com:petersmith/super_calculator",
|
||||
func(repoInfo *RepoInformation) {
|
||||
@@ -24,6 +26,16 @@ func TestGetRepoInfoFromURL(t *testing.T) {
|
||||
},
|
||||
},
|
||||
{
|
||||
NewGithubService("github.com", "github.com"),
|
||||
"Returns repository information for git remote url, trimming trailing '.git'",
|
||||
"git@github.com:petersmith/super_calculator.git",
|
||||
func(repoInfo *RepoInformation) {
|
||||
assert.EqualValues(t, repoInfo.Owner, "petersmith")
|
||||
assert.EqualValues(t, repoInfo.Repository, "super_calculator")
|
||||
},
|
||||
},
|
||||
{
|
||||
NewGithubService("github.com", "github.com"),
|
||||
"Returns repository information for http remote url",
|
||||
"https://my_username@bitbucket.org/johndoe/social_network.git",
|
||||
func(repoInfo *RepoInformation) {
|
||||
@@ -35,7 +47,7 @@ func TestGetRepoInfoFromURL(t *testing.T) {
|
||||
|
||||
for _, s := range scenarios {
|
||||
t.Run(s.testName, func(t *testing.T) {
|
||||
s.test(getRepoInfoFromURL(s.repoURL))
|
||||
s.test(s.service.getRepoInfoFromURL(s.repoURL))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user