cmd/gitmirror: add tests
Add integration tests. They're on the slow side, as much as a second per
test, but the coverage is pretty solid and I hope they'll be easy to
read and maintain.
The tests run a real mirror, but without the normal driver loop and with
the repositories redirected to point to the local filesystem. That costs
us coverage of things like the gerrit polling, but removes the timing
sensitivity. I think that's a reasonable tradeoff; we'd just be mocking
maintner and gerrit anyway.
Also fix a bug that the tests surfaced: we can't run clone in the
directory we want it to create.
Change-Id: I8fa319b9bd3de194e75a2fdc2ee5a5cef71ec1aa
Reviewed-on: https://go-review.googlesource.com/c/build/+/324762
Trust: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
diff --git a/repos/repos.go b/repos/repos.go
index 5c81b7e..6ab6310 100644
--- a/repos/repos.go
+++ b/repos/repos.go
@@ -36,10 +36,10 @@
// build coordinator knows how to build.
CoordinatorCanBuild bool
- // gitHubRepo is the "org/repo" of where this repo exists on
+ // GitHubRepo is the "org/repo" of where this repo exists on
// GitHub. If MirrorToGitHub is true, this is the
// destination.
- gitHubRepo string
+ GitHubRepo string
// WebsiteDesc is the description of the repo for showing on
// https://golang.org/pkg/#subrepo.
@@ -103,13 +103,13 @@
GoGerritProject: "protobuf",
MirrorToGitHub: true,
ImportPath: "google.golang.org/protobuf",
- gitHubRepo: "protocolbuffers/protobuf-go",
+ GitHubRepo: "protocolbuffers/protobuf-go",
})
add(&Repo{
GoGerritProject: "vscode-go",
MirrorToGitHub: true,
- gitHubRepo: "golang/vscode-go",
+ GitHubRepo: "golang/vscode-go",
})
}
@@ -138,7 +138,7 @@
repo := &Repo{
GoGerritProject: proj,
MirrorToGitHub: true,
- gitHubRepo: "golang/" + proj,
+ GitHubRepo: "golang/" + proj,
}
for _, o := range opts {
o(repo)
@@ -153,7 +153,7 @@
MirrorToGitHub: true,
CoordinatorCanBuild: true,
ImportPath: "golang.org/x/" + proj,
- gitHubRepo: "golang/" + proj,
+ GitHubRepo: "golang/" + proj,
showOnDashboard: true,
}
for _, o := range opts {
@@ -166,7 +166,7 @@
if (r.MirrorToCSR || r.MirrorToGitHub || r.showOnDashboard) && r.GoGerritProject == "" {
panic(fmt.Sprintf("project %+v sets feature(s) that require a GoGerritProject, but has none", r))
}
- if r.MirrorToGitHub && r.gitHubRepo == "" {
+ if r.MirrorToGitHub && r.GitHubRepo == "" {
panic(fmt.Sprintf("project %+v has MirrorToGitHub but no gitHubRepo", r))
}
if r.showOnDashboard && !r.CoordinatorCanBuild {
@@ -192,8 +192,3 @@
//
// When this returns true, r.GoGerritProject is guaranteed to be non-empty.
func (r *Repo) ShowOnDashboard() bool { return r.showOnDashboard }
-
-// GitHubRepo returns the "<org>/<repo>" that this repo either lives
-// at or is mirrored to. It returns the empty string if this repo has no
-// GitHub presence.
-func (r *Repo) GitHubRepo() string { return r.gitHubRepo }