@@ -16,3 +16,41 @@ func Test_repoFromURL(t *testing.T) {
1616 t .Errorf ("got Name: %q" , r .Name )
1717 }
1818}
19+
20+ func Test_parseRemotes (t * testing.T ) {
21+ remoteList := []string {
22+ "mona\t git@github.com:monalisa/myfork.git (fetch)" ,
23+ "origin\t https://github.com/monalisa/octo-cat.git (fetch)" ,
24+ "origin\t https://github.com/monalisa/octo-cat-push.git (push)" ,
25+ "upstream\t https://example.com/nowhere.git (fetch)" ,
26+ "upstream\t https://github.com/hubot/tools (push)" ,
27+ }
28+ r , err := parseRemotes (remoteList )
29+ if err != nil {
30+ t .Error (err )
31+ }
32+
33+ mona , err := r .FindByName ("mona" )
34+ if err != nil {
35+ t .Error (err )
36+ }
37+ if mona .Owner != "monalisa" || mona .Repo != "myfork" {
38+ t .Errorf ("got %s/%s" , mona .Owner , mona .Repo )
39+ }
40+
41+ origin , err := r .FindByName ("origin" )
42+ if err != nil {
43+ t .Error (err )
44+ }
45+ if origin .Owner != "monalisa" || origin .Repo != "octo-cat" {
46+ t .Errorf ("got %s/%s" , origin .Owner , origin .Repo )
47+ }
48+
49+ upstream , err := r .FindByName ("upstream" )
50+ if err != nil {
51+ t .Error (err )
52+ }
53+ if upstream .Owner != "hubot" || upstream .Repo != "tools" {
54+ t .Errorf ("got %s/%s" , upstream .Owner , upstream .Repo )
55+ }
56+ }
0 commit comments