-
Notifications
You must be signed in to change notification settings - Fork 60
/
Copy pathvcs_remote_lookup_test.go
49 lines (43 loc) · 2.14 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
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 VcsType
}{
"https://github.com/masterminds": {work: false, t: GitType},
"https://github.com/Masterminds/VCSTestRepo": {work: true, t: GitType},
"https://bitbucket.org/mattfarina/testhgrepo": {work: true, t: HgType},
"https://launchpad.net/govcstestbzrrepo/trunk": {work: true, t: BzrType},
"https://launchpad.net/~mattfarina/+junk/mygovcstestbzrrepo": {work: true, t: BzrType},
"https://launchpad.net/~mattfarina/+junk/mygovcstestbzrrepo/trunk": {work: true, t: BzrType},
"https://git.launchpad.net/govcstestgitrepo": {work: true, t: GitType},
"https://git.launchpad.net/~mattfarina/+git/mygovcstestgitrepo": {work: true, t: GitType},
"http://farbtastic.googlecode.com/svn/": {work: true, t: SvnType},
"http://farbtastic.googlecode.com/svn/trunk": {work: true, t: SvnType},
"https://code.google.com/p/farbtastic": {work: false, t: SvnType},
"https://code.google.com/p/plotinum": {work: true, t: HgType},
"https://example.com/foo/bar.git": {work: true, t: GitType},
"https://example.com/foo/bar.svn": {work: true, t: SvnType},
"https://example.com/foo/bar/baz.bzr": {work: true, t: BzrType},
"https://example.com/foo/bar/baz.hg": {work: true, t: HgType},
}
for u, c := range urlList {
ty, err := detectVcsFromUrl(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)
}
}
}