1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-12-18 08:26:45 +02:00
woodpecker/pkg/build/repo/repo_test.go

55 lines
1.3 KiB
Go
Raw Normal View History

2014-02-07 13:10:01 +03:00
package repo
import (
"testing"
)
func TestIsRemote(t *testing.T) {
repos := []struct {
path string
remote bool
}{
{"git://github.com/foo/far", true},
{"git://github.com/foo/far.git", true},
{"git@github.com:foo/far", true},
{"git@github.com:foo/far.git", true},
{"http://github.com/foo/far.git", true},
{"https://github.com/foo/far.git", true},
{"ssh://baz.com/foo/far.git", true},
{"/var/lib/src", false},
{"/home/ubuntu/src", false},
{"src", false},
}
for _, r := range repos {
repo := Repo{Path: r.path}
if remote := repo.IsRemote(); remote != r.remote {
t.Errorf("IsRemote %s was %v, expected %v", r.path, remote, r.remote)
}
}
}
func TestIsGit(t *testing.T) {
repos := []struct {
path string
remote bool
}{
{"git://github.com/foo/far", true},
{"git://github.com/foo/far.git", true},
{"git@github.com:foo/far", true},
{"git@github.com:foo/far.git", true},
{"http://github.com/foo/far.git", true},
{"https://github.com/foo/far.git", true},
{"ssh://baz.com/foo/far.git", true},
{"svn://gcc.gnu.org/svn/gcc/branches/gccgo", false},
{"https://code.google.com/p/go", false},
}
for _, r := range repos {
repo := Repo{Path: r.path}
if remote := repo.IsGit(); remote != r.remote {
t.Errorf("IsGit %s was %v, expected %v", r.path, remote, r.remote)
}
}
}