Jelajahi Sumber

Run golangci-lint run --fix

Signed-off-by: Shengqi Chen <harry-chen@outlook.com>
Shengqi Chen 8 bulan lalu
induk
melakukan
ab416f6545
3 mengubah file dengan 24 tambahan dan 27 penghapusan
  1. 1 2
      internal/status_web_test.go
  2. 22 22
      manager/server_test.go
  3. 1 3
      worker/two_stage_rsync_provider.go

+ 1 - 2
internal/status_web_test.go

@@ -71,8 +71,7 @@ func TestStatus(t *testing.T) {
 			Size:        "4GB",
 		}
 
-		var m2 WebMirrorStatus
-		m2 = BuildWebMirrorStatus(m)
+		var m2 WebMirrorStatus = BuildWebMirrorStatus(m)
 		// fmt.Printf("%#v", m2)
 		So(m2.Name, ShouldEqual, m.Name)
 		So(m2.Status, ShouldEqual, m.Status)

+ 22 - 22
manager/server_test.go

@@ -180,9 +180,9 @@ func TestHTTPServer(t *testing.T) {
 					So(m.Upstream, ShouldEqual, status.Upstream)
 					So(m.Size, ShouldEqual, status.Size)
 					So(m.IsMaster, ShouldEqual, status.IsMaster)
-					So(time.Now().Sub(m.LastUpdate), ShouldBeLessThan, 1*time.Second)
+					So(time.Since(m.LastUpdate), ShouldBeLessThan, 1*time.Second)
 					So(m.LastStarted.IsZero(), ShouldBeTrue) // hasn't been initialized yet
-					So(time.Now().Sub(m.LastEnded), ShouldBeLessThan, 1*time.Second)
+					So(time.Since(m.LastEnded), ShouldBeLessThan, 1*time.Second)
 
 				})
 
@@ -208,11 +208,11 @@ func TestHTTPServer(t *testing.T) {
 					So(m.Upstream, ShouldEqual, status.Upstream)
 					So(m.Size, ShouldEqual, status.Size)
 					So(m.IsMaster, ShouldEqual, status.IsMaster)
-					So(time.Now().Sub(m.LastUpdate), ShouldBeLessThan, 3*time.Second)
-					So(time.Now().Sub(m.LastUpdate), ShouldBeGreaterThan, 1*time.Second)
-					So(time.Now().Sub(m.LastStarted), ShouldBeLessThan, 2*time.Second)
-					So(time.Now().Sub(m.LastEnded), ShouldBeLessThan, 3*time.Second)
-					So(time.Now().Sub(m.LastEnded), ShouldBeGreaterThan, 1*time.Second)
+					So(time.Since(m.LastUpdate), ShouldBeLessThan, 3*time.Second)
+					So(time.Since(m.LastUpdate), ShouldBeGreaterThan, 1*time.Second)
+					So(time.Since(m.LastStarted), ShouldBeLessThan, 2*time.Second)
+					So(time.Since(m.LastEnded), ShouldBeLessThan, 3*time.Second)
+					So(time.Since(m.LastEnded), ShouldBeGreaterThan, 1*time.Second)
 
 				})
 
@@ -228,9 +228,9 @@ func TestHTTPServer(t *testing.T) {
 					So(m.Upstream, ShouldEqual, status.Upstream)
 					So(m.Size, ShouldEqual, status.Size)
 					So(m.IsMaster, ShouldEqual, status.IsMaster)
-					So(time.Now().Sub(m.LastUpdate.Time), ShouldBeLessThan, 3*time.Second)
-					So(time.Now().Sub(m.LastStarted.Time), ShouldBeLessThan, 2*time.Second)
-					So(time.Now().Sub(m.LastEnded.Time), ShouldBeLessThan, 3*time.Second)
+					So(time.Since(m.LastUpdate.Time), ShouldBeLessThan, 3*time.Second)
+					So(time.Since(m.LastStarted.Time), ShouldBeLessThan, 2*time.Second)
+					So(time.Since(m.LastEnded.Time), ShouldBeLessThan, 3*time.Second)
 
 				})
 
@@ -259,17 +259,17 @@ func TestHTTPServer(t *testing.T) {
 						So(m.Upstream, ShouldEqual, status.Upstream)
 						So(m.Size, ShouldEqual, "5GB")
 						So(m.IsMaster, ShouldEqual, status.IsMaster)
-						So(time.Now().Sub(m.LastUpdate), ShouldBeLessThan, 3*time.Second)
-						So(time.Now().Sub(m.LastStarted), ShouldBeLessThan, 2*time.Second)
-						So(time.Now().Sub(m.LastEnded), ShouldBeLessThan, 3*time.Second)
+						So(time.Since(m.LastUpdate), ShouldBeLessThan, 3*time.Second)
+						So(time.Since(m.LastStarted), ShouldBeLessThan, 2*time.Second)
+						So(time.Since(m.LastEnded), ShouldBeLessThan, 3*time.Second)
 					})
 				})
 
 				Convey("Update schedule of valid mirrors", func(ctx C) {
 					msg := MirrorSchedules{
-						[]MirrorSchedule{
-							MirrorSchedule{"arch-sync1", time.Now().Add(time.Minute * 10)},
-							MirrorSchedule{"arch-sync2", time.Now().Add(time.Minute * 7)},
+						Schedules: []MirrorSchedule{
+							MirrorSchedule{MirrorName: "arch-sync1", NextSchedule: time.Now().Add(time.Minute * 10)},
+							MirrorSchedule{MirrorName: "arch-sync2", NextSchedule: time.Now().Add(time.Minute * 7)},
 						},
 					}
 
@@ -313,9 +313,9 @@ func TestHTTPServer(t *testing.T) {
 					So(m.Upstream, ShouldEqual, status.Upstream)
 					So(m.Size, ShouldEqual, status.Size)
 					So(m.IsMaster, ShouldEqual, status.IsMaster)
-					So(time.Now().Sub(m.LastUpdate), ShouldBeGreaterThan, 3*time.Second)
-					So(time.Now().Sub(m.LastStarted), ShouldBeGreaterThan, 3*time.Second)
-					So(time.Now().Sub(m.LastEnded), ShouldBeLessThan, 1*time.Second)
+					So(time.Since(m.LastUpdate), ShouldBeGreaterThan, 3*time.Second)
+					So(time.Since(m.LastStarted), ShouldBeGreaterThan, 3*time.Second)
+					So(time.Since(m.LastEnded), ShouldBeLessThan, 1*time.Second)
 				})
 			})
 
@@ -345,9 +345,9 @@ func TestHTTPServer(t *testing.T) {
 			Convey("update schedule of an non-existent worker", func(ctx C) {
 				invalidWorker := "test_worker2"
 				sch := MirrorSchedules{
-					[]MirrorSchedule{
-						MirrorSchedule{"arch-sync1", time.Now().Add(time.Minute * 10)},
-						MirrorSchedule{"arch-sync2", time.Now().Add(time.Minute * 7)},
+					Schedules: []MirrorSchedule{
+						MirrorSchedule{MirrorName: "arch-sync1", NextSchedule: time.Now().Add(time.Minute * 10)},
+						MirrorSchedule{MirrorName: "arch-sync2", NextSchedule: time.Now().Add(time.Minute * 7)},
 					},
 				}
 				resp, err := PostJSON(fmt.Sprintf("%s/workers/%s/schedules",

+ 1 - 3
worker/two_stage_rsync_provider.go

@@ -127,9 +127,7 @@ func (p *twoStageRsyncProvider) Options(stage int) ([]string, error) {
 		if !ok {
 			return nil, errors.New("Invalid Stage 1 Profile")
 		}
-		for _, exc := range stage1Profile {
-			options = append(options, exc)
-		}
+		options = append(options, stage1Profile...)
 
 	} else if stage == 2 {
 		options = append(options, p.stage2Options...)