From 775919c1299bb78c8f8b4ad498385b086ab33b6f Mon Sep 17 00:00:00 2001 From: Unknwon Date: Wed, 30 May 2018 21:26:03 +0800 Subject: mirror: show sync feeds on dashboard (#2017) --- models/mirror_test.go | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'models/mirror_test.go') 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 { -- cgit v1.2.3