File tree Expand file tree Collapse file tree 2 files changed +42
-2
lines changed
pkg/patterns/addon/pkg/loaders Expand file tree Collapse file tree 2 files changed +42
-2
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ var _ Repository = &GitRepository{}
22
22
23
23
// NewGitRepository constructs an GitRepository
24
24
func NewGitRepository (baseurl string ) * GitRepository {
25
- baseurl , subDir := parseGitUrl (baseurl )
25
+ baseurl , subDir := parseGitURL (baseurl )
26
26
return & GitRepository {
27
27
baseURL : baseurl ,
28
28
subDir : subDir ,
@@ -119,7 +119,7 @@ func (r *GitRepository) readURL(url string) ([]byte, error) {
119
119
return b , nil
120
120
}
121
121
122
- func parseGitUrl (url string ) (string , string ){
122
+ func parseGitURL (url string ) (string , string ){
123
123
// checks for git:: suffix
124
124
var subdir string
125
125
if strings .HasPrefix (url , "git::" ) {
Original file line number Diff line number Diff line change
1
+ package loaders
2
+
3
+ import (
4
+ "testing"
5
+ )
6
+
7
+ func TestParseGitURL (t * testing.T ) {
8
+ tests := []struct {
9
+ rawURL string
10
+ baseURL string
11
+ subDir string
12
+ }{
13
+ {
14
+ rawURL : "https://github.com/testRepository.git" ,
15
+ baseURL : "https://github.com/testRepository.git" ,
16
+ subDir : "" ,
17
+ },
18
+ {
19
+ rawURL : "git::https://github.com/testRepository.git" ,
20
+ baseURL : "https://github.com/testRepository.git" ,
21
+ subDir : "" ,
22
+ },
23
+ {
24
+ rawURL : "git::https://github.com/testRepository.git//subDir/package" ,
25
+ baseURL : "https://github.com/testRepository.git" ,
26
+ subDir : "subDir/package" ,
27
+ },
28
+ }
29
+
30
+ for _ , tt := range tests {
31
+ actualBase , actualSubDir := parseGitURL (tt .rawURL )
32
+ if actualBase != tt .baseURL {
33
+ t .Errorf ("Expected base url: %v, got %v" , tt .baseURL , actualBase )
34
+ }
35
+
36
+ if actualSubDir != tt .subDir {
37
+ t .Errorf ("Expected base url: %v, got %v" , tt .subDir , actualSubDir )
38
+ }
39
+ }
40
+ }
You can’t perform that action at this time.
0 commit comments