github.com/marinho/drone@v0.2.1-0.20140504195434-d3ba962e89a7/pkg/build/repo/repo_test.go (about) 1 package repo 2 3 import ( 4 "testing" 5 ) 6 7 func TestIsRemote(t *testing.T) { 8 repos := []struct { 9 path string 10 remote bool 11 }{ 12 {"git://github.com/foo/far", true}, 13 {"git://github.com/foo/far.git", true}, 14 {"git@github.com:foo/far", true}, 15 {"git@github.com:foo/far.git", true}, 16 {"http://github.com/foo/far.git", true}, 17 {"https://github.com/foo/far.git", true}, 18 {"ssh://baz.com/foo/far.git", true}, 19 {"/var/lib/src", false}, 20 {"/home/ubuntu/src", false}, 21 {"src", false}, 22 } 23 24 for _, r := range repos { 25 repo := Repo{Path: r.path} 26 if remote := repo.IsRemote(); remote != r.remote { 27 t.Errorf("IsRemote %s was %v, expected %v", r.path, remote, r.remote) 28 } 29 } 30 } 31 32 func TestIsGit(t *testing.T) { 33 repos := []struct { 34 path string 35 remote bool 36 }{ 37 {"git://github.com/foo/far", true}, 38 {"git://github.com/foo/far.git", true}, 39 {"git@github.com:foo/far", true}, 40 {"git@github.com:foo/far.git", true}, 41 {"http://github.com/foo/far.git", true}, 42 {"https://github.com/foo/far.git", true}, 43 {"ssh://baz.com/foo/far.git", true}, 44 {"svn://gcc.gnu.org/svn/gcc/branches/gccgo", false}, 45 {"https://code.google.com/p/go", false}, 46 } 47 48 for _, r := range repos { 49 repo := Repo{Path: r.path} 50 if remote := repo.IsGit(); remote != r.remote { 51 t.Errorf("IsGit %s was %v, expected %v", r.path, remote, r.remote) 52 } 53 } 54 }