1package tests
2
3import (
4 "testing"
5
6 "github.com/MichaelMure/git-bug/entities/bug"
7 "github.com/MichaelMure/git-bug/misc/random_bugs"
8 "github.com/MichaelMure/git-bug/repository"
9)
10
11func TestReadBugs(t *testing.T) {
12 repo := repository.CreateGoGitTestRepo(t, false)
13
14 random_bugs.FillRepoWithSeed(repo, 15, 42)
15
16 bugs := bug.ReadAll(repo)
17 for b := range bugs {
18 if b.Err != nil {
19 t.Fatal(b.Err)
20 }
21 }
22}
23
24func benchmarkReadBugs(bugNumber int, t *testing.B) {
25 repo := repository.CreateGoGitTestRepo(t, false)
26
27 random_bugs.FillRepoWithSeed(repo, bugNumber, 42)
28 t.ResetTimer()
29
30 for n := 0; n < t.N; n++ {
31 bugs := bug.ReadAll(repo)
32 for b := range bugs {
33 if b.Err != nil {
34 t.Fatal(b.Err)
35 }
36 }
37 }
38}
39
40func BenchmarkReadBugs5(b *testing.B) { benchmarkReadBugs(5, b) }
41func BenchmarkReadBugs25(b *testing.B) { benchmarkReadBugs(25, b) }
42func BenchmarkReadBugs150(b *testing.B) { benchmarkReadBugs(150, b) }