@@ -10,20 +10,29 @@ import (
10
10
)
11
11
12
12
func TestCommitSubmoduleLink (t * testing.T ) {
13
- sf := NewCommitSubmoduleFile (
"[email protected] :user/repo.git" ,
"aaaa" )
13
+ wl := (* CommitSubmoduleFile )(nil ).SubmoduleWebLink (t .Context ())
14
+ assert .Nil (t , wl )
14
15
15
- wl := sf .SubmoduleWebLink (t .Context ())
16
- assert .Equal (t , "https://github.com/user/repo" , wl .RepoWebLink )
17
- assert .Equal (t , "https://github.com/user/repo/tree/aaaa" , wl .CommitWebLink )
16
+ t .Run ("GitHubRepo" , func (t * testing.T ) {
17
+ sf := NewCommitSubmoduleFile (
"[email protected] :user/repo.git" ,
"aaaa" )
18
18
19
- wl = sf .SubmoduleWebLink (t .Context (), "1111" )
20
- assert .Equal (t , "https://github.com/user/repo" , wl .RepoWebLink )
21
- assert .Equal (t , "https://github.com/user/repo/tree/1111 " , wl .CommitWebLink )
19
+ wl : = sf .SubmoduleWebLink (t .Context ())
20
+ assert .Equal (t , "https://github.com/user/repo" , wl .RepoWebLink )
21
+ assert .Equal (t , "https://github.com/user/repo/tree/aaaa " , wl .CommitWebLink )
22
22
23
- wl = sf .SubmoduleWebLink (t .Context (), "1111" , "2222 " )
24
- assert .Equal (t , "https://github.com/user/repo" , wl .RepoWebLink )
25
- assert .Equal (t , "https://github.com/user/repo/compare /1111...2222 " , wl .CommitWebLink )
23
+ wl = sf .SubmoduleWebLink (t .Context (), "1111" )
24
+ assert .Equal (t , "https://github.com/user/repo" , wl .RepoWebLink )
25
+ assert .Equal (t , "https://github.com/user/repo/tree /1111" , wl .CommitWebLink )
26
26
27
- wl = (* CommitSubmoduleFile )(nil ).SubmoduleWebLink (t .Context ())
28
- assert .Nil (t , wl )
27
+ wl = sf .SubmoduleWebLink (t .Context (), "1111" , "2222" )
28
+ assert .Equal (t , "https://github.com/user/repo" , wl .RepoWebLink )
29
+ assert .Equal (t , "https://github.com/user/repo/compare/1111...2222" , wl .CommitWebLink )
30
+ })
31
+
32
+ t .Run ("RelativePath" , func (t * testing.T ) {
33
+ sf := NewCommitSubmoduleFile ("../../user/repo" , "aaaa" )
34
+ wl := sf .SubmoduleWebLink (t .Context ())
35
+ assert .Equal (t , "../../user/repo" , wl .RepoWebLink )
36
+ assert .Equal (t , "../../user/repo/tree/aaaa" , wl .CommitWebLink )
37
+ })
29
38
}
0 commit comments