Skip to content

Commit 76a9d05

Browse files
committed
source: more tests cases for git identifier
Signed-off-by: CrazyMax <[email protected]>
1 parent c8e589f commit 76a9d05

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed

source/gitidentifier_test.go

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,77 @@ func TestNewGitIdentifier(t *testing.T) {
3737
Ref: "main",
3838
},
3939
},
40+
{
41+
url: "git://github.com/user/repo.git",
42+
expected: GitIdentifier{
43+
Remote: "git://github.com/user/repo.git",
44+
},
45+
},
46+
{
47+
url: "git://github.com/user/repo.git#mybranch:mydir/mysubdir/",
48+
expected: GitIdentifier{
49+
Remote: "git://github.com/user/repo.git",
50+
Ref: "mybranch",
51+
Subdir: "mydir/mysubdir/",
52+
},
53+
},
54+
{
55+
url: "git://github.com/user/repo.git#:mydir/mysubdir/",
56+
expected: GitIdentifier{
57+
Remote: "git://github.com/user/repo.git",
58+
Subdir: "mydir/mysubdir/",
59+
},
60+
},
61+
{
62+
url: "https://github.com/user/repo.git",
63+
expected: GitIdentifier{
64+
Remote: "https://github.com/user/repo.git",
65+
},
66+
},
67+
{
68+
url: "https://github.com/user/repo.git#mybranch:mydir/mysubdir/",
69+
expected: GitIdentifier{
70+
Remote: "https://github.com/user/repo.git",
71+
Ref: "mybranch",
72+
Subdir: "mydir/mysubdir/",
73+
},
74+
},
75+
{
76+
url: "[email protected]:user/repo.git",
77+
expected: GitIdentifier{
78+
Remote: "[email protected]:user/repo.git",
79+
},
80+
},
81+
{
82+
url: "[email protected]:user/repo.git#mybranch:mydir/mysubdir/",
83+
expected: GitIdentifier{
84+
Remote: "[email protected]:user/repo.git",
85+
Ref: "mybranch",
86+
Subdir: "mydir/mysubdir/",
87+
},
88+
},
89+
{
90+
url: "ssh://github.com/user/repo.git",
91+
expected: GitIdentifier{
92+
Remote: "ssh://github.com/user/repo.git",
93+
},
94+
},
95+
{
96+
url: "ssh://github.com/user/repo.git#mybranch:mydir/mysubdir/",
97+
expected: GitIdentifier{
98+
Remote: "ssh://github.com/user/repo.git",
99+
Ref: "mybranch",
100+
Subdir: "mydir/mysubdir/",
101+
},
102+
},
103+
{
104+
url: "ssh://foo%[email protected]/user/repo.git#mybranch:mydir/mysubdir/",
105+
expected: GitIdentifier{
106+
Remote: "ssh://foo%[email protected]/user/repo.git",
107+
Ref: "mybranch",
108+
Subdir: "mydir/mysubdir/",
109+
},
110+
},
40111
}
41112
for _, tt := range tests {
42113
tt := tt

0 commit comments

Comments
 (0)