gopkg.in/tools/godep.v78@v78.0.0-20170123184621-47355da3e1a3/vcs_test.go (about) 1 package main 2 3 import "testing" 4 5 func TestGitDetermineDefaultBranch(t *testing.T) { 6 cases := []struct { 7 r, o string 8 v string 9 err bool 10 }{ 11 {"test", 12 `* remote origin 13 Fetch URL: https://gopkg.in/mgo.v2 14 Push URL: https://gopkg.in/mgo.v2 15 HEAD branch: v2 16 Remote branches: 17 master tracked 18 v2 tracked 19 v2-unstable tracked 20 Local branches configured for 'git pull': 21 master merges with remote master 22 v2 merges with remote v2 23 Local refs configured for 'git push': 24 master pushes to master (up to date) 25 v2 pushes to v2 (local out of date) 26 `, "v2", false}, 27 {"test", 28 `* remote origin 29 Fetch URL: https://gopkg.in/bluesuncorp/validator.v5 30 Push URL: https://gopkg.in/bluesuncorp/validator.v5 31 HEAD branch (remote HEAD is ambiguous, may be one of the following): 32 master 33 v5 34 Remote branches: 35 krhubert tracked 36 master tracked 37 v4 tracked 38 v5 tracked 39 v5-development tracked 40 v6 tracked 41 v6-development tracked 42 v7 tracked 43 v7-development tracked 44 v8 tracked 45 v8-development tracked 46 Local branch configured for 'git pull': 47 master merges with remote master 48 Local ref configured for 'git push': 49 master pushes to master (up to date) 50 `, "master", false}, 51 {"test", 52 `* remote origin 53 Fetch URL: https://github.com/gin-gonic/gin 54 Push URL: https://github.com/gin-gonic/gin 55 HEAD branch: develop 56 Remote branches: 57 benchmarks tracked 58 better-bind-errors tracked 59 develop tracked 60 fasthttp tracked 61 fix-binding tracked 62 fix-tests tracked 63 gh-pages tracked 64 honteng-bind_test tracked 65 master tracked 66 new-binding-validator tracked 67 new-catch-all tracked 68 performance tracked 69 routes-list tracked 70 Local branch configured for 'git pull': 71 develop merges with remote develop 72 Local ref configured for 'git push': 73 develop pushes to develop (local out of date) 74 `, "develop", false}, 75 {"test", "", "", true}, 76 } 77 78 for i, test := range cases { 79 v, e := gitDetermineDefaultBranch(test.r, test.o) 80 if v != test.v { 81 t.Errorf("%d Unexpected value returned: %s, wanted %s", i, v, test.v) 82 } 83 if e != nil { 84 t.Log("Err", e.Error()) 85 } 86 if test.err && e == nil { 87 t.Errorf("%d Test should err, but didn't", i) 88 } 89 90 if !test.err && e != nil { 91 t.Errorf("%d Test shouldn't err, but did with: %s", i, e) 92 } 93 } 94 }