-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(account): handle invalid repository domain matches (#137)
fixes #136 Signed-off-by: Jacob LeGrone <[email protected]>
- Loading branch information
1 parent
c97c790
commit ea18dc6
Showing
2 changed files
with
27 additions
and
15 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
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 |
---|---|---|
@@ -1,27 +1,32 @@ | ||
package tool | ||
|
||
import ( | ||
"github.com/stretchr/testify/assert" | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestParseOutGitDomain(t *testing.T) { | ||
var testDataSlice = []struct { | ||
name string | ||
repoUrl string | ||
expected string | ||
err error | ||
}{ | ||
{"GitHub SSH", "[email protected]:foo/bar", "github.com"}, | ||
{"GitHub HTTPS", "https://github.com/foo/bar", "github.com"}, | ||
{"Gitlab SSH", "[email protected]:foo/bar", "gitlab.com"}, | ||
{"Gitlab HTTPS", "https://gitlab.com/foo/bar", "gitlab.com"}, | ||
{"Bitbucket SSH", "[email protected]:foo/bar", "bitbucket.com"}, | ||
{"Bitbucket HTTPS", "https://bitbucket.com/foo/bar", "bitbucket.com"}, | ||
{"GitHub SSH", "[email protected]:foo/bar", "github.com", nil}, | ||
{"GitHub HTTPS", "https://github.com/foo/bar", "github.com", nil}, | ||
{"Gitlab SSH", "[email protected]:foo/bar", "gitlab.com", nil}, | ||
{"Gitlab HTTPS", "https://gitlab.com/foo/bar", "gitlab.com", nil}, | ||
{"Bitbucket SSH", "[email protected]:foo/bar", "bitbucket.com", nil}, | ||
{"Bitbucket HTTPS", "https://bitbucket.com/foo/bar", "bitbucket.com", nil}, | ||
{"Invalid", "foo/bar", "", fmt.Errorf("Could not parse git repository domain for 'foo/bar'")}, | ||
} | ||
|
||
for _, testData := range testDataSlice { | ||
t.Run(testData.name, func(t *testing.T) { | ||
actual := parseOutGitRepoDomain(testData.repoUrl) | ||
actual, err := parseOutGitRepoDomain(testData.repoUrl) | ||
assert.Equal(t, err, testData.err) | ||
assert.Equal(t, testData.expected, actual) | ||
}) | ||
} | ||
|