aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2019-05-27 21:14:55 +0200
committerMichael Muré <batolettre@gmail.com>2019-05-27 21:14:55 +0200
commitc7abac388aadd274d4f23f996a15f8bba90f2a92 (patch)
treeced1116de500346eb340f72b7bfc672136e40c1e /tests
parent9865dfcdf0810e288283f2ef4eba450041db32f9 (diff)
downloadgit-bug-c7abac388aadd274d4f23f996a15f8bba90f2a92.tar.gz
repo: refactor how test repo are created/cleaned
Diffstat (limited to 'tests')
-rw-r--r--tests/read_bugs_test.go22
1 files changed, 8 insertions, 14 deletions
diff --git a/tests/read_bugs_test.go b/tests/read_bugs_test.go
index 8b4379e7..c510fdbe 100644
--- a/tests/read_bugs_test.go
+++ b/tests/read_bugs_test.go
@@ -6,23 +6,14 @@ import (
"github.com/MichaelMure/git-bug/bug"
"github.com/MichaelMure/git-bug/misc/random_bugs"
"github.com/MichaelMure/git-bug/repository"
- "github.com/MichaelMure/git-bug/util/test"
)
-func CreateFilledRepo(bugNumber int) repository.ClockedRepo {
- repo := test.CreateRepo(false)
-
- var seed int64 = 42
- options := random_bugs.DefaultOptions()
-
- options.BugNumber = bugNumber
+func TestReadBugs(t *testing.T) {
+ repo := repository.CreateTestRepo(false)
+ defer repository.CleanupTestRepos(t, repo)
- random_bugs.CommitRandomBugsWithSeed(repo, options, seed)
- return repo
-}
+ random_bugs.FillRepoWithSeed(repo, 15, 42)
-func TestReadBugs(t *testing.T) {
- repo := CreateFilledRepo(15)
bugs := bug.ReadAllLocalBugs(repo)
for b := range bugs {
if b.Err != nil {
@@ -32,7 +23,10 @@ func TestReadBugs(t *testing.T) {
}
func benchmarkReadBugs(bugNumber int, t *testing.B) {
- repo := CreateFilledRepo(bugNumber)
+ repo := repository.CreateTestRepo(false)
+ defer repository.CleanupTestRepos(t, repo)
+
+ random_bugs.FillRepoWithSeed(repo, bugNumber, 42)
t.ResetTimer()
for n := 0; n < t.N; n++ {