aboutsummaryrefslogtreecommitdiffstats
path: root/models/graph_test.go
diff options
context:
space:
mode:
authorKjell Kvinge <kjell@kvinge.biz>2018-07-21 20:17:10 +0200
committertechknowlogick <techknowlogick@users.noreply.github.com>2018-07-21 14:17:09 -0400
commitbed623600d18dac84d17e41a47a8119098dc1d47 (patch)
tree13a8ef1aa28d3c722a80d9fb6f04ac1b62bb9169 /models/graph_test.go
parent5fa403c874ef32053f3e04fba7e7b1f605842900 (diff)
downloadgitea-bed623600d18dac84d17e41a47a8119098dc1d47.tar.gz
gitea-bed623600d18dac84d17e41a47a8119098dc1d47.zip
Accept 'Data:' in commit graph (#4487)
Diffstat (limited to 'models/graph_test.go')
-rw-r--r--models/graph_test.go30
1 files changed, 30 insertions, 0 deletions
diff --git a/models/graph_test.go b/models/graph_test.go
index 47c9dbb084..0f6e338792 100644
--- a/models/graph_test.go
+++ b/models/graph_test.go
@@ -5,6 +5,7 @@
package models
import (
+ "fmt"
"testing"
"code.gitea.io/git"
@@ -43,3 +44,32 @@ func BenchmarkParseCommitString(b *testing.B) {
}
}
}
+
+func TestCommitStringParsing(t *testing.T) {
+ dataFirstPart := "* DATA:||4e61bacab44e9b4730e44a6615d04098dd3a8eaf|2016-12-20 21:10:41 +0100|Author|user@mail.something|4e61bac|"
+ tests := []struct {
+ shouldPass bool
+ testName string
+ commitMessage string
+ }{
+ {true, "normal", "not a fancy message"},
+ {true, "extra pipe", "An extra pipe: |"},
+ {true, "extra 'Data:'", "DATA: might be trouble"},
+ }
+
+ for _, test := range tests {
+
+ t.Run(test.testName, func(t *testing.T) {
+ testString := fmt.Sprintf("%s%s", dataFirstPart, test.commitMessage)
+ graphItem, err := graphItemFromString(testString, nil)
+ if err != nil && test.shouldPass {
+ t.Errorf("Could not parse %s", testString)
+ return
+ }
+
+ if test.commitMessage != graphItem.Subject {
+ t.Errorf("%s does not match %s", test.commitMessage, graphItem.Subject)
+ }
+ })
+ }
+}