Files
gitleaks/leaks_test.go
T
Matthias Derer 9c1ea12d77 Generate the local repoName
To support other URLs than standard github URLs, the repoName
is now being generated based on the given URL.

Currently supported are formats for HTTP, SSH and local paths.

Fixes #4
2018-02-15 15:54:02 +01:00

54 lines
913 B
Go

package main
import "testing"
func TestGetLocalRepoName(t *testing.T) {
cases := []struct{
name string
input string
expected string
}{
{
"Usual github url",
"https://github.com/usual/url",
"url",
},
{
"Usual github url with .git suffix",
"https://github.com/usual/url.git",
"url",
},
{
"personal git url",
"git@github.com:url.git",
"url",
},
{
"personal git url in sub folder",
"git@github.com:sub/url.git",
"url",
},
{
"ssh git url with port",
"ssh://git@github.com:2222/sub/url.git",
"url",
},
{
"local git in sub folder",
"local/url.git",
"url",
},
{
"local git in same folder",
"url.git",
"url",
},
}
for _, c := range cases {
actual := getLocalRepoName(c.input)
if actual != c.expected {
t.Errorf("'%s' failed. Input: '%s'; Expected: '%s'; Got: '%s'", c.input, c.name, c.expected, actual)
}
}
}