Skip to content

Commit 4b0974e

Browse files
kjellkvingelunny
authored andcommitted
Fix benchmarktests (#557)
1 parent 7be02d9 commit 4b0974e

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

models/graph_test.go

+17-13
Original file line numberDiff line numberDiff line change
@@ -17,25 +17,29 @@ func BenchmarkGetCommitGraph(b *testing.B) {
1717
b.Error("Could not open repository")
1818
}
1919

20-
graph, err := GetCommitGraph(currentRepo)
21-
if err != nil {
22-
b.Error("Could get commit graph")
23-
}
24-
25-
if len(graph) < 100 {
26-
b.Error("Should get 100 log lines.")
20+
for i := 0; i < b.N; i++ {
21+
graph, err := GetCommitGraph(currentRepo)
22+
if err != nil {
23+
b.Error("Could get commit graph")
24+
}
25+
26+
if len(graph) < 100 {
27+
b.Error("Should get 100 log lines.")
28+
}
2729
}
2830
}
2931

3032
func BenchmarkParseCommitString(b *testing.B) {
3133
testString := "* DATA:||4e61bacab44e9b4730e44a6615d04098dd3a8eaf|2016-12-20 21:10:41 +0100|Kjell Kvinge|[email protected]|4e61bac|Add route for graph"
3234

33-
graphItem, err := graphItemFromString(testString, nil)
34-
if err != nil {
35-
b.Error("could not parse teststring")
36-
}
35+
for i := 0; i < b.N; i++ {
36+
graphItem, err := graphItemFromString(testString, nil)
37+
if err != nil {
38+
b.Error("could not parse teststring")
39+
}
3740

38-
if graphItem.Author != "Kjell Kvinge" {
39-
b.Error("Did not get expected data")
41+
if graphItem.Author != "Kjell Kvinge" {
42+
b.Error("Did not get expected data")
43+
}
4044
}
4145
}

0 commit comments

Comments
 (0)