aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bug_actions_test.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2018-08-12 21:09:46 +0200
committerMichael Muré <batolettre@gmail.com>2018-08-12 21:09:46 +0200
commit83185a8cb32d866bb88d31b00439c94ce29e0e84 (patch)
treed7eb03381496439d38aeda3cf660d87f808c873b /tests/bug_actions_test.go
parente2f4b027c946831c3f4f119d87a80513c7cf8fdc (diff)
downloadgit-bug-83185a8cb32d866bb88d31b00439c94ce29e0e84.tar.gz
test: make bug_actions_test race resistant
Diffstat (limited to 'tests/bug_actions_test.go')
-rw-r--r--tests/bug_actions_test.go42
1 files changed, 20 insertions, 22 deletions
diff --git a/tests/bug_actions_test.go b/tests/bug_actions_test.go
index 847c3661..96f1bc74 100644
--- a/tests/bug_actions_test.go
+++ b/tests/bug_actions_test.go
@@ -41,11 +41,7 @@ func cleanupRepo(repo repository.Repo) error {
return os.RemoveAll(path)
}
-var repoA *repository.GitRepo
-var repoB *repository.GitRepo
-var remote *repository.GitRepo
-
-func setupRepos(t *testing.T) {
+func setupRepos(t *testing.T) (repoA, repoB, remote *repository.GitRepo) {
repoA = createRepo(false)
repoB = createRepo(false)
remote = createRepo(true)
@@ -61,17 +57,19 @@ func setupRepos(t *testing.T) {
if err != nil {
t.Fatal(err)
}
+
+ return repoA, repoB, remote
}
-func cleanupRepos() {
+func cleanupRepos(repoA, repoB, remote *repository.GitRepo) {
cleanupRepo(repoA)
cleanupRepo(repoB)
cleanupRepo(remote)
}
func TestPushPull(t *testing.T) {
- setupRepos(t)
- defer cleanupRepos()
+ repoA, repoB, remote := setupRepos(t)
+ defer cleanupRepos(repoA, repoB, remote)
bug1, err := operations.Create(rene, "bug1", "message")
checkErr(t, err)
@@ -79,7 +77,7 @@ func TestPushPull(t *testing.T) {
checkErr(t, err)
// A --> remote --> B
- err = bug.Push(repoA, "origin")
+ _, err = bug.Push(repoA, "origin")
checkErr(t, err)
err = bug.Pull(repoB, os.Stdout, "origin")
@@ -97,7 +95,7 @@ func TestPushPull(t *testing.T) {
bug2.Commit(repoB)
checkErr(t, err)
- err = bug.Push(repoB, "origin")
+ _, err = bug.Push(repoB, "origin")
checkErr(t, err)
err = bug.Pull(repoA, os.Stdout, "origin")
@@ -128,8 +126,8 @@ func allBugs(t *testing.T, bugs <-chan bug.StreamedBug) []*bug.Bug {
}
func TestRebaseTheirs(t *testing.T) {
- setupRepos(t)
- defer cleanupRepos()
+ repoA, repoB, remote := setupRepos(t)
+ defer cleanupRepos(repoA, repoB, remote)
bug1, err := operations.Create(rene, "bug1", "message")
checkErr(t, err)
@@ -137,7 +135,7 @@ func TestRebaseTheirs(t *testing.T) {
checkErr(t, err)
// A --> remote
- err = bug.Push(repoA, "origin")
+ _, err = bug.Push(repoA, "origin")
checkErr(t, err)
// remote --> B
@@ -154,7 +152,7 @@ func TestRebaseTheirs(t *testing.T) {
checkErr(t, err)
// B --> remote
- err = bug.Push(repoB, "origin")
+ _, err = bug.Push(repoB, "origin")
checkErr(t, err)
// remote --> A
@@ -176,8 +174,8 @@ func TestRebaseTheirs(t *testing.T) {
}
func TestRebaseOurs(t *testing.T) {
- setupRepos(t)
- defer cleanupRepos()
+ repoA, repoB, remote := setupRepos(t)
+ defer cleanupRepos(repoA, repoB, remote)
bug1, err := operations.Create(rene, "bug1", "message")
checkErr(t, err)
@@ -185,7 +183,7 @@ func TestRebaseOurs(t *testing.T) {
checkErr(t, err)
// A --> remote
- err = bug.Push(repoA, "origin")
+ _, err = bug.Push(repoA, "origin")
checkErr(t, err)
// remote --> B
@@ -238,8 +236,8 @@ func nbOps(b *bug.Bug) int {
}
func TestRebaseConflict(t *testing.T) {
- setupRepos(t)
- defer cleanupRepos()
+ repoA, repoB, remote := setupRepos(t)
+ defer cleanupRepos(repoA, repoB, remote)
bug1, err := operations.Create(rene, "bug1", "message")
checkErr(t, err)
@@ -247,7 +245,7 @@ func TestRebaseConflict(t *testing.T) {
checkErr(t, err)
// A --> remote
- err = bug.Push(repoA, "origin")
+ _, err = bug.Push(repoA, "origin")
checkErr(t, err)
// remote --> B
@@ -294,7 +292,7 @@ func TestRebaseConflict(t *testing.T) {
checkErr(t, err)
// A --> remote
- err = bug.Push(repoA, "origin")
+ _, err = bug.Push(repoA, "origin")
checkErr(t, err)
// remote --> B
@@ -315,7 +313,7 @@ func TestRebaseConflict(t *testing.T) {
}
// B --> remote
- err = bug.Push(repoB, "origin")
+ _, err = bug.Push(repoB, "origin")
checkErr(t, err)
// remote --> A