diff --git a/internal/status_web_test.go b/internal/status_web_test.go index cc2dda8..c89009b 100644 --- a/internal/status_web_test.go +++ b/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) diff --git a/manager/server_test.go b/manager/server_test.go index 46afe1a..18b0dc8 100644 --- a/manager/server_test.go +++ b/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", diff --git a/worker/two_stage_rsync_provider.go b/worker/two_stage_rsync_provider.go index 5efd87c..2c8a845 100644 --- a/worker/two_stage_rsync_provider.go +++ b/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...)