@@ -38,19 +38,32 @@ func TestIsGitUrl(t *testing.T) {
3838 }
3939}
4040
41- func TestRepositoryURLToGitURL (t * testing.T ) {
42- // Test table: Given url, RepositoryURLToGitURL should return expect.
41+ func TestParseGitRepositoryURL (t * testing.T ) {
42+ // Test table: Given url, ParseGitRepositoryURL should return expect.
4343 tests := []struct {
44- url string
45- expect string
44+ url string
45+ expectRepositoryURL string
46+ expectGitRepositoryURL string
4647 }{
47- {"git://example.com/example/chart" , "git://example.com/example/chart" },
48- {"git+https://example.com/example/chart" , "https://example.com/example/chart" },
48+ {
49+ url : "git://example.com/example/chart" ,
50+ expectRepositoryURL : "git://example.com/example/chart" ,
51+ expectGitRepositoryURL : "git://example.com/example/chart" ,
52+ },
53+ {
54+ url : "git+https://example.com/example/chart" ,
55+ expectRepositoryURL : "git+https://example.com/example/chart" ,
56+ expectGitRepositoryURL : "https://example.com/example/chart" ,
57+ },
4958 }
5059
5160 for _ , test := range tests {
52- if RepositoryURLToGitURL (test .url ) != test .expect {
53- t .Errorf ("Expected %s for %s" , test .expect , test .url )
61+ parsed , _ := ParseGitRepositoryURL (test .url )
62+ if parsed .RepositoryURL != test .expectRepositoryURL {
63+ t .Errorf ("Expected RepositoryURL %s for %s, but got %s" , test .expectRepositoryURL , test .url , parsed )
64+ }
65+ if parsed .GitRemoteURL .String () != test .expectGitRepositoryURL {
66+ t .Errorf ("Expected GitRemoteURL %s for %s, but got %s" , test .expectGitRepositoryURL , test .url , parsed )
5467 }
5568 }
5669}
0 commit comments