Fix benchmarktests (#557)

tokarchuk/v1.17
Kjell Kvinge 8 years ago committed by Lunny Xiao
parent 7be02d9020
commit 4b0974ec10
  1. 30
      models/graph_test.go

@ -17,25 +17,29 @@ func BenchmarkGetCommitGraph(b *testing.B) {
b.Error("Could not open repository") b.Error("Could not open repository")
} }
graph, err := GetCommitGraph(currentRepo) for i := 0; i < b.N; i++ {
if err != nil { graph, err := GetCommitGraph(currentRepo)
b.Error("Could get commit graph") if err != nil {
} b.Error("Could get commit graph")
}
if len(graph) < 100 {
b.Error("Should get 100 log lines.") if len(graph) < 100 {
b.Error("Should get 100 log lines.")
}
} }
} }
func BenchmarkParseCommitString(b *testing.B) { func BenchmarkParseCommitString(b *testing.B) {
testString := "* DATA:||4e61bacab44e9b4730e44a6615d04098dd3a8eaf|2016-12-20 21:10:41 +0100|Kjell Kvinge|kjell@kvinge.biz|4e61bac|Add route for graph" testString := "* DATA:||4e61bacab44e9b4730e44a6615d04098dd3a8eaf|2016-12-20 21:10:41 +0100|Kjell Kvinge|kjell@kvinge.biz|4e61bac|Add route for graph"
graphItem, err := graphItemFromString(testString, nil) for i := 0; i < b.N; i++ {
if err != nil { graphItem, err := graphItemFromString(testString, nil)
b.Error("could not parse teststring") if err != nil {
} b.Error("could not parse teststring")
}
if graphItem.Author != "Kjell Kvinge" { if graphItem.Author != "Kjell Kvinge" {
b.Error("Did not get expected data") b.Error("Did not get expected data")
}
} }
} }

Loading…
Cancel
Save