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