diff options
| author | Dmitry Vyukov <dvyukov@google.com> | 2017-11-16 10:12:17 +0100 |
|---|---|---|
| committer | Dmitry Vyukov <dvyukov@google.com> | 2017-11-16 10:12:17 +0100 |
| commit | 9a98ae3fb64f0aeac0336263590ddcff6c581024 (patch) | |
| tree | 31110be8d0cd9a5450099896c197175e5d5591e1 /pkg/git/git_test.go | |
| parent | 95cf3e724785cf8d46beec31c4a009b5a4c6af91 (diff) | |
pkg/git: provide more helper functions
Add Patch, Checkout, CheckRepoAddress and CheckBranch.
Will be needed for patch testing.
Diffstat (limited to 'pkg/git/git_test.go')
| -rw-r--r-- | pkg/git/git_test.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/pkg/git/git_test.go b/pkg/git/git_test.go index 42d2d3a07..3cc1300dd 100644 --- a/pkg/git/git_test.go +++ b/pkg/git/git_test.go @@ -21,3 +21,54 @@ func TestCanonicalizeCommit(t *testing.T) { } } } + +func TestCheckRepoAddress(t *testing.T) { + var tests = []struct { + repo string + result bool + }{ + {"git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git", true}, + {"https://github.com/torvalds/linux.git", true}, + {"git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git", true}, + {"git://git.cmpxchg.org/linux-mmots.git", true}, + {"https://anonscm.debian.org/git/kernel/linux.git", true}, + {"git://kernel.ubuntu.com/ubuntu/ubuntu-zesty.git", true}, + {"http://host.xz:123/path/to/repo.git/", true}, + {"", false}, + {"foobar", false}, + {"linux-next", false}, + {"foo://kernel.ubuntu.com/ubuntu/ubuntu-zesty.git", false}, + {"git://kernel/ubuntu.git", false}, + {"git://kernel.com/ubuntu", false}, + {"gitgit://kernel.ubuntu.com/ubuntu/ubuntu-zesty.git", false}, + } + for _, test := range tests { + res := CheckRepoAddress(test.repo) + if res != test.result { + t.Errorf("%v: got %v, want %v", test.repo, res, test.result) + } + } +} + +func TestCheckBranch(t *testing.T) { + var tests = []struct { + branch string + result bool + }{ + {"master", true}, + {"core/core", true}, + {"irq-irqdomain-for-linus", true}, + {"timers/2038", true}, + {"ubuntu-zesty/v4.9.4", true}, + {"WIP.locking/atomics", true}, + {"linux-4.9.y", true}, + {"abi_spec", true}, + {"@", false}, + } + for _, test := range tests { + res := CheckBranch(test.branch) + if res != test.result { + t.Errorf("%v: got %v, want %v", test.branch, res, test.result) + } + } +} |
