mirror of
https://github.com/helm/chart-testing.git
synced 2026-02-05 09:45:14 +01:00
* upgrade to go1.19 Signed-off-by: cpanato <ctadeu@gmail.com> * add golangci-lint Signed-off-by: cpanato <ctadeu@gmail.com> * fix lints and Replace github.com/pkg/errors dependency with native error wrapping Signed-off-by: cpanato <ctadeu@gmail.com> * update install kind cluster Signed-off-by: cpanato <ctadeu@gmail.com> * update tests Signed-off-by: cpanato <ctadeu@gmail.com> * use errors.new Signed-off-by: cpanato <ctadeu@gmail.com> Signed-off-by: cpanato <ctadeu@gmail.com>
37 lines
1.3 KiB
Go
37 lines
1.3 KiB
Go
package tool
|
|
|
|
import (
|
|
"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", "git@github.com:foo/bar", "github.com", nil},
|
|
{"GitHub HTTPS", "https://github.com/foo/bar", "github.com", nil},
|
|
{"GitHub HTTPS with username/password", "https://foo:token@github.com/foo/bar", "github.com", nil},
|
|
{"Gitlab SSH", "git@gitlab.com:foo/bar", "gitlab.com", nil},
|
|
{"Gitlab HTTPS", "https://gitlab.com/foo/bar", "gitlab.com", nil},
|
|
{"Gitlab HTTPS with username/password", "https://gitlab-ci-token:password@gitlab.com/foo/bar", "gitlab.com", nil},
|
|
{"Bitbucket SSH", "git@bitbucket.com:foo/bar", "bitbucket.com", nil},
|
|
{"Bitbucket HTTPS", "https://bitbucket.com/foo/bar", "bitbucket.com", nil},
|
|
{"Bitbucket HTTPS with username/password", "https://user:pass@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, err := parseOutGitRepoDomain(testData.repoURL)
|
|
assert.Equal(t, err, testData.err)
|
|
assert.Equal(t, testData.expected, actual)
|
|
})
|
|
}
|
|
}
|