@@ -9,9 +9,10 @@ import (
99
1010func TestParseRepo (t * testing.T ) {
1111 var tests = []struct {
12- defSchema string
13- defHost string
14- fullPath string
12+ defSchema string
13+ defHost string
14+ defOrganization string
15+ fullPath string
1516
1617 expPath string
1718 expHost string
@@ -23,6 +24,7 @@ func TestParseRepo(t *testing.T) {
2324 {
2425 "ssh" ,
2526 "github.com" ,
27+ "" ,
2628 "cdr/sail" ,
2729 "cdr/sail" ,
2830 "github.com" ,
@@ -34,6 +36,7 @@ func TestParseRepo(t *testing.T) {
3436 {
3537 "http" ,
3638 "github.com" ,
39+ "" ,
3740 "cdr/sail" ,
3841 "cdr/sail" ,
3942 "github.com" ,
@@ -45,6 +48,7 @@ func TestParseRepo(t *testing.T) {
4548 {
4649 "https" ,
4750 "github.com" ,
51+ "" ,
4852 "cdr/sail" ,
4953 "cdr/sail" ,
5054 "github.com" ,
@@ -56,6 +60,7 @@ func TestParseRepo(t *testing.T) {
5660 {
5761 "https" ,
5862 "github.com" ,
63+ "" ,
5964 "https://github.com/cdr/sail" ,
6065 "cdr/sail" ,
6166 "github.com" ,
@@ -67,6 +72,7 @@ func TestParseRepo(t *testing.T) {
6772 {
6873 "ssh" ,
6974 "github.com" ,
75+ "" ,
7076 "git@github.com/cdr/sail.git" ,
7177 "cdr/sail" ,
7278 "github.com" ,
@@ -78,6 +84,7 @@ func TestParseRepo(t *testing.T) {
7884 {
7985 "http" ,
8086 "github.com" ,
87+ "" ,
8188 "ssh://git@github.com/cdr/sail" ,
8289 "cdr/sail" ,
8390 "github.com" ,
@@ -89,17 +96,30 @@ func TestParseRepo(t *testing.T) {
8996 {
9097 "https" ,
9198 "my.private-git.com" ,
99+ "" ,
92100 "private/repo" ,
93101 "private/repo" ,
94102 "my.private-git.com" ,
95103 "" ,
96104 "https" ,
97105 "https://my.private-git.com/private/repo.git" ,
98106 },
107+ // ensure default organization works as expected
108+ {
109+ "ssh" ,
110+ "github.com" ,
111+ "cdr" ,
112+ "sail" ,
113+ "cdr/sail" ,
114+ "github.com" ,
115+ "git" ,
116+ "ssh" ,
117+ "ssh://git@github.com/cdr/sail.git" ,
118+ },
99119 }
100120
101121 for _ , test := range tests {
102- repo , err := parseRepo (test .defSchema , test .defHost , test .fullPath )
122+ repo , err := parseRepo (test .defSchema , test .defHost , test .defOrganization , test . fullPath )
103123 require .NoError (t , err )
104124
105125 assert .Equal (t , test .expPath , repo .Path , "expected path to be the same" )
0 commit comments