summaryrefslogtreecommitdiffstats
path: root/models/graph_test.go
diff options
context:
space:
mode:
authorKjell Kvinge <kjell@kvinge.biz>2016-12-29 00:44:32 +0100
committerLunny Xiao <xiaolunwen@gmail.com>2016-12-29 07:44:32 +0800
commit22e1bd31c68586e963262db964d6a83f6115e56f (patch)
tree39d669cd4b982063512320e91ed359357a518f1f /models/graph_test.go
parent35d9378e4e1b3b1c15db3a7e7237a55fa96919a1 (diff)
downloadgitea-22e1bd31c68586e963262db964d6a83f6115e56f.tar.gz
gitea-22e1bd31c68586e963262db964d6a83f6115e56f.zip
commithgraph / timeline (#428)
* Add model and tests for graph * Add route and router for graph * Add assets for graph * Add template for graph
Diffstat (limited to 'models/graph_test.go')
-rw-r--r--models/graph_test.go41
1 files changed, 41 insertions, 0 deletions
diff --git a/models/graph_test.go b/models/graph_test.go
new file mode 100644
index 0000000000..23d8aa8492
--- /dev/null
+++ b/models/graph_test.go
@@ -0,0 +1,41 @@
+// Copyright 2016 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package models
+
+import (
+ "testing"
+
+ "code.gitea.io/git"
+)
+
+func BenchmarkGetCommitGraph(b *testing.B) {
+
+ currentRepo, err := git.OpenRepository(".")
+ if err != nil {
+ b.Error("Could not open repository")
+ }
+
+ graph, err := GetCommitGraph(currentRepo)
+ if err != nil {
+ b.Error("Could get commit graph")
+ }
+
+ if len(graph) < 100 {
+ b.Error("Should get 100 log lines.")
+ }
+}
+
+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"
+
+ graphItem, err := graphItemFromString(testString, nil)
+ if err != nil {
+ b.Error("could not parse teststring")
+ }
+
+ if graphItem.Author != "Kjell Kvinge" {
+ b.Error("Did not get expected data")
+ }
+}