@@ -41,29 +41,39 @@ func TestIsGitUrl(t *testing.T) {
4141func TestParseGitRepositoryURL (t * testing.T ) {
4242 // Test table: Given url, ParseGitRepositoryURL should return expect.
4343 tests := []struct {
44- url string
45- expectRepositoryURL string
46- expectGitRepositoryURL string
44+ url string
45+ expectRepositoryURL string
46+ expectGitRemoteURL string
47+ expectedPathUnderGitRepository string
4748 }{
4849 {
49- url : "git://example.com/example/chart" ,
50- expectRepositoryURL : "git://example.com/example/chart" ,
51- expectGitRepositoryURL : "git://example.com/example/chart" ,
50+ url : "git://example.com/example/chart" ,
51+ expectRepositoryURL : "git://example.com/example/chart" ,
52+ expectGitRemoteURL : "git://example.com/example/chart" ,
5253 },
5354 {
54- url : "git+https://example.com/example/chart" ,
55- expectRepositoryURL : "git+https://example.com/example/chart" ,
56- expectGitRepositoryURL : "https://example.com/example/chart" ,
55+ url : "git+https://example.com/example/chart" ,
56+ expectRepositoryURL : "git+https://example.com/example/chart" ,
57+ expectGitRemoteURL : "https://example.com/example/chart" ,
58+ },
59+ {
60+ url : "git+https://example.com/example/chart#subdirectory=charts/some-chart" ,
61+ expectRepositoryURL : "git+https://example.com/example/chart#subdirectory=charts/some-chart" ,
62+ expectGitRemoteURL : "https://example.com/example/chart" ,
63+ expectedPathUnderGitRepository : "charts/some-chart" ,
5764 },
5865 }
5966
6067 for _ , test := range tests {
6168 parsed , _ := ParseGitRepositoryURL (test .url )
6269 if parsed .RepositoryURL != test .expectRepositoryURL {
63- t .Errorf ("Expected RepositoryURL %s for %s, but got %s" , test .expectRepositoryURL , test .url , parsed )
70+ t .Errorf ("Expected RepositoryURL %s for %s, but got %s" , test .expectRepositoryURL , test .url , parsed .RepositoryURL )
71+ }
72+ if parsed .GitRemoteURL .String () != test .expectGitRemoteURL {
73+ t .Errorf ("Expected GitRemoteURL %s for %s, but got %s" , test .expectGitRemoteURL , test .url , parsed .GitRemoteURL )
6474 }
65- if parsed .GitRemoteURL . String () != test .expectGitRepositoryURL {
66- t .Errorf ("Expected GitRemoteURL %s for %s, but got %s" , test .expectGitRepositoryURL , test .url , parsed )
75+ if parsed .PathUnderGitRepository != test .expectedPathUnderGitRepository {
76+ t .Errorf ("Expected PathUnderGitRepository %s for %s, but got %s" , test .expectGitRemoteURL , test .url , parsed . PathUnderGitRepository )
6777 }
6878 }
6979}
0 commit comments