package app import ( "testing" "github.com/stretchr/testify/assert" ) func TestParseGitRemoteUrl(t *testing.T) { tests := []struct { url string scheme string expectedDomain string expectedRepo string }{ {"https://cnb.cool/looc/git-cnb.git", "https", "cnb.cool", "looc/git-cnb"}, {"http://cnb.cool/looc/cnb/git-cnb.git", "http", "cnb.cool", "looc/cnb/git-cnb"}, {"https://cnb.cool/looc/git-cnb.git", "https", "cnb.cool", "looc/git-cnb"}, {"https://cnb:fsdfasdfasdfasdfsdf@cnb.cool/looc/git-cnb.git", "https", "cnb.cool", "looc/git-cnb"}, } for _, test := range tests { t.Run(test.url, func(t *testing.T) { scheme, domain, repo, _ := parseGitRemoteUrl(test.url) assert.Equal(t, test.scheme, scheme, "Expected scheme %s, but got %s for URL: %s", test.scheme, scheme, test.url) assert.Equal(t, test.expectedDomain, domain, "Expected domain %s, but got %s for URL: %s", test.expectedDomain, domain, test.url) assert.Equal(t, test.expectedRepo, repo, "Expected domain %s, but got %s for URL: %s", test.expectedRepo, repo, test.url) }) } }