-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathvcs_remote_lookup_test.go
62 lines (56 loc) · 3.24 KB
/
vcs_remote_lookup_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package vcs
import (
"testing"
)
func TestVCSLookup(t *testing.T) {
// TODO: Expand to make sure it detected the right vcs.
urlList := map[string]struct {
work bool
t Type
}{
"https://github.com/masterminds": {work: false, t: Git},
"https://github.com/Masterminds/VCSTestRepo": {work: true, t: Git},
"https://bitbucket.org/mattfarina/testhgrepo": {work: true, t: Hg},
"https://launchpad.net/govcstestbzrrepo/trunk": {work: true, t: Bzr},
"https://launchpad.net/~mattfarina/+junk/mygovcstestbzrrepo": {work: true, t: Bzr},
"https://launchpad.net/~mattfarina/+junk/mygovcstestbzrrepo/trunk": {work: true, t: Bzr},
"https://git.launchpad.net/govcstestgitrepo": {work: true, t: Git},
"https://git.launchpad.net/~mattfarina/+git/mygovcstestgitrepo": {work: true, t: Git},
"https://hub.jazz.net/git/user1/pkgname": {work: true, t: Git},
"https://hub.jazz.net/git/user1/pkgname/subpkg/subpkg/subpkg": {work: true, t: Git},
"https://hubs.jazz.net/git/user1/pkgname": {work: false, t: Git},
"http://farbtastic.googlecode.com/svn/": {work: true, t: Svn},
"http://farbtastic.googlecode.com/svn/trunk": {work: true, t: Svn},
"https://example.com/foo/bar.git": {work: true, t: Git},
"https://example.com/foo/bar.svn": {work: true, t: Svn},
"https://example.com/foo/bar/baz.bzr": {work: true, t: Bzr},
"https://example.com/foo/bar/baz.hg": {work: true, t: Hg},
"https://gopkg.in/tomb.v1": {work: true, t: Git},
"https://golang.org/x/net": {work: true, t: Git},
"https://speter.net/go/exp/math/dec/inf": {work: true, t: Git},
"git@github.com:Masterminds/vcs.git": {work: true, t: Git},
"git@example.com:foo.git": {work: true, t: Git},
"ssh://hg@bitbucket.org/mattfarina/testhgrepo": {work: true, t: Hg},
"git@bitbucket.org:mattfarina/glide-bitbucket-example.git": {work: true, t: Git},
"git+ssh://example.com/foo/bar": {work: true, t: Git},
"bzr+ssh://example.com/foo/bar": {work: true, t: Bzr},
"svn+ssh://example.com/foo/bar": {work: true, t: Svn},
"git@example.com:foo/bar": {work: true, t: Git},
"hg@example.com:foo/bar": {work: true, t: Hg},
}
for u, c := range urlList {
ty, _, err := detectVcsFromRemote(u)
if err == nil && c.work == false {
t.Errorf("Error detecting VCS from URL(%s)", u)
}
if err == ErrCannotDetectVCS && c.work == true {
t.Errorf("Error detecting VCS from URL(%s)", u)
}
if err != nil && c.work == true {
t.Errorf("Error detecting VCS from URL(%s): %s", u, err)
}
if c.work == true && ty != c.t {
t.Errorf("Incorrect VCS type returned(%s)", u)
}
}
}