github.com/sc0rp1us/gb@v0.4.1-0.20160319180011-4ba8cf1baa5a/vendor/repo_test.go (about) 1 package vendor 2 3 import ( 4 "fmt" 5 "reflect" 6 "testing" 7 ) 8 9 func TestDeduceRemoteRepo(t *testing.T) { 10 if testing.Short() { 11 t.Skipf("skipping network tests in -short mode") 12 } 13 tests := []struct { 14 path string 15 want RemoteRepo 16 extra string 17 err error 18 insecure bool 19 }{{ 20 path: "", 21 err: fmt.Errorf(`"" is not a valid import path`), 22 }, { 23 path: "corporate", 24 err: fmt.Errorf(`"corporate" is not a valid import path`), 25 }, { 26 path: "github.com/cznic/b", 27 want: &gitrepo{ 28 url: "https://github.com/cznic/b", 29 }, 30 }, { 31 path: "github.com/pkg/sftp", 32 want: &gitrepo{ 33 url: "https://github.com/pkg/sftp", 34 }, 35 }, { 36 path: "github.com/pkg/sftp/examples/gsftp", 37 want: &gitrepo{ 38 url: "https://github.com/pkg/sftp", 39 }, 40 extra: "/examples/gsftp", 41 }, { 42 path: "github.com/coreos/go-etcd", 43 want: &gitrepo{ 44 url: "https://github.com/coreos/go-etcd", 45 }, 46 /* 47 bitbucket cannot maintain a stable ssh key across their app servers 48 and this mucks up ci testing because mercurial does not have any 49 way of unconditionally accepting new ssh keys for the host. 50 Great work TEAM. 51 }, { 52 path: "bitbucket.org/davecheney/gitrepo/cmd/main", 53 want: &gitrepo{ 54 url: "https://bitbucket.org/davecheney/gitrepo", 55 }, 56 extra: "/cmd/main", 57 }, { 58 path: "bitbucket.org/davecheney/hgrepo/cmd/main", 59 want: &hgrepo{ 60 url: "https://bitbucket.org/davecheney/hgrepo", 61 }, 62 extra: "/cmd/main", 63 */ 64 }, { 65 path: "code.google.com/p/goauth2/oauth", 66 want: &hgrepo{ 67 url: "https://code.google.com/p/goauth2", 68 }, 69 extra: "/oauth", 70 }, { 71 path: "code.google.com/p/gami", 72 want: &gitrepo{ 73 url: "https://code.google.com/p/gami", 74 }, 75 }, { 76 path: "git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.golang.git", 77 want: &gitrepo{ 78 url: "https://git.eclipse.org/gitroot/paho/org.eclipse.paho.mqtt.golang.git", 79 }, 80 }, { 81 path: "git.apache.org/thrift.git/lib/go/thrift", 82 want: &gitrepo{ 83 url: "https://git.apache.org/thrift.git", 84 }, 85 extra: "/lib/go/thrift", 86 }, { 87 path: "gopkg.in/check.v1", 88 want: &gitrepo{ 89 url: "https://gopkg.in/check.v1", 90 }, 91 extra: "", 92 }, { 93 path: "goji.io", 94 want: &gitrepo{ 95 url: "https://github.com/goji/goji", 96 }, 97 extra: "", 98 }, { 99 path: "golang.org/x/tools/go/vcs", 100 want: &gitrepo{ 101 url: "https://go.googlesource.com/tools", 102 }, 103 extra: "/go/vcs", 104 }, { 105 path: "labix.org/v2/mgo", 106 want: &bzrrepo{ 107 url: "https://launchpad.net/mgo/v2", 108 }, 109 insecure: true, 110 }, { 111 path: "launchpad.net/gnuflag", 112 want: &bzrrepo{ 113 url: "https://launchpad.net/gnuflag", 114 }, 115 }, { 116 path: "https://github.com/pkg/sftp", 117 want: &gitrepo{ 118 url: "https://github.com/pkg/sftp", 119 }, 120 }, { 121 path: "git://github.com/pkg/sftp", 122 want: &gitrepo{ 123 url: "git://github.com/pkg/sftp", 124 }, 125 insecure: true, 126 }, { 127 path: "code.google.com/p/google-api-go-client/bigquery/v2", 128 want: &hgrepo{ 129 url: "https://code.google.com/p/google-api-go-client", 130 }, 131 extra: "/bigquery/v2", 132 }, { 133 path: "code.google.com/p/go-sqlite/go1/sqlite3", 134 want: &hgrepo{ 135 url: "https://code.google.com/p/go-sqlite", 136 }, 137 extra: "/go1/sqlite3", 138 }} 139 140 for _, tt := range tests { 141 t.Logf("DeduceRemoteRepo(%q, %v)", tt.path, tt.insecure) 142 got, extra, err := DeduceRemoteRepo(tt.path, tt.insecure) 143 if !reflect.DeepEqual(err, tt.err) { 144 t.Errorf("DeduceRemoteRepo(%q): want err: %v, got err: %v", tt.path, tt.err, err) 145 continue 146 } 147 if !reflect.DeepEqual(got, tt.want) || extra != tt.extra { 148 t.Errorf("DeduceRemoteRepo(%q): want %#v, %v, got %#v, %v", tt.path, tt.want, tt.extra, got, extra) 149 } 150 } 151 }