aboutsummaryrefslogtreecommitdiff
path: root/models/mirror_test.go
diff options
context:
space:
mode:
authorUnknwon <u@gogs.io>2018-05-30 21:26:03 +0800
committerUnknwon <u@gogs.io>2018-05-30 21:26:03 +0800
commit775919c1299bb78c8f8b4ad498385b086ab33b6f (patch)
tree23b5cd74717f5972988a8134692eb10e3cba0214 /models/mirror_test.go
parent702acc06d8a6346aecc9abd9ce1b7f2da7f49e42 (diff)
mirror: show sync feeds on dashboard (#2017)
Diffstat (limited to 'models/mirror_test.go')
-rw-r--r--models/mirror_test.go34
1 files changed, 34 insertions, 0 deletions
diff --git a/models/mirror_test.go b/models/mirror_test.go
index b4af58ba..d6e86502 100644
--- a/models/mirror_test.go
+++ b/models/mirror_test.go
@@ -10,6 +10,40 @@ import (
. "github.com/smartystreets/goconvey/convey"
)
+func Test_parseRemoteUpdateOutput(t *testing.T) {
+ Convey("Parse mirror remote update output", t, func() {
+ testCases := []struct {
+ output string
+ results []*mirrorSyncResult
+ }{
+ {
+ `
+From https://try.gogs.io/unknwon/upsteam
+ * [new branch] develop -> develop
+ b0bb24f..1d85a4f master -> master
+ - [deleted] (none) -> bugfix
+`,
+ []*mirrorSyncResult{
+ {"develop", GIT_SHORT_EMPTY_SHA, ""},
+ {"master", "b0bb24f", "1d85a4f"},
+ {"bugfix", "", GIT_SHORT_EMPTY_SHA},
+ },
+ },
+ }
+
+ for _, tc := range testCases {
+ results := parseRemoteUpdateOutput(tc.output)
+ So(len(results), ShouldEqual, len(tc.results))
+
+ for i := range tc.results {
+ So(tc.results[i].refName, ShouldEqual, results[i].refName)
+ So(tc.results[i].oldCommitID, ShouldEqual, results[i].oldCommitID)
+ So(tc.results[i].newCommitID, ShouldEqual, results[i].newCommitID)
+ }
+ }
+ })
+}
+
func Test_findPasswordInMirrorAddress(t *testing.T) {
Convey("Find password portion in mirror address", t, func() {
testCases := []struct {