@@ -10,20 +10,29 @@ import (
1010)
1111
1212func 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 )
1415
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" )
1818
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 )
2222
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 )
2626
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+ })
2938}
0 commit comments