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