mirror of
https://github.com/tuna/tunasync.git
synced 2025-06-13 21:12:43 +00:00
Run golangci-lint run --fix
Signed-off-by: Shengqi Chen <harry-chen@outlook.com>
This commit is contained in:
parent
15e87a5f48
commit
ab416f6545
@ -71,8 +71,7 @@ func TestStatus(t *testing.T) {
|
|||||||
Size: "4GB",
|
Size: "4GB",
|
||||||
}
|
}
|
||||||
|
|
||||||
var m2 WebMirrorStatus
|
var m2 WebMirrorStatus = BuildWebMirrorStatus(m)
|
||||||
m2 = BuildWebMirrorStatus(m)
|
|
||||||
// fmt.Printf("%#v", m2)
|
// fmt.Printf("%#v", m2)
|
||||||
So(m2.Name, ShouldEqual, m.Name)
|
So(m2.Name, ShouldEqual, m.Name)
|
||||||
So(m2.Status, ShouldEqual, m.Status)
|
So(m2.Status, ShouldEqual, m.Status)
|
||||||
|
@ -180,9 +180,9 @@ func TestHTTPServer(t *testing.T) {
|
|||||||
So(m.Upstream, ShouldEqual, status.Upstream)
|
So(m.Upstream, ShouldEqual, status.Upstream)
|
||||||
So(m.Size, ShouldEqual, status.Size)
|
So(m.Size, ShouldEqual, status.Size)
|
||||||
So(m.IsMaster, ShouldEqual, status.IsMaster)
|
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(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.Upstream, ShouldEqual, status.Upstream)
|
||||||
So(m.Size, ShouldEqual, status.Size)
|
So(m.Size, ShouldEqual, status.Size)
|
||||||
So(m.IsMaster, ShouldEqual, status.IsMaster)
|
So(m.IsMaster, ShouldEqual, status.IsMaster)
|
||||||
So(time.Now().Sub(m.LastUpdate), ShouldBeLessThan, 3*time.Second)
|
So(time.Since(m.LastUpdate), ShouldBeLessThan, 3*time.Second)
|
||||||
So(time.Now().Sub(m.LastUpdate), ShouldBeGreaterThan, 1*time.Second)
|
So(time.Since(m.LastUpdate), ShouldBeGreaterThan, 1*time.Second)
|
||||||
So(time.Now().Sub(m.LastStarted), ShouldBeLessThan, 2*time.Second)
|
So(time.Since(m.LastStarted), ShouldBeLessThan, 2*time.Second)
|
||||||
So(time.Now().Sub(m.LastEnded), ShouldBeLessThan, 3*time.Second)
|
So(time.Since(m.LastEnded), ShouldBeLessThan, 3*time.Second)
|
||||||
So(time.Now().Sub(m.LastEnded), ShouldBeGreaterThan, 1*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.Upstream, ShouldEqual, status.Upstream)
|
||||||
So(m.Size, ShouldEqual, status.Size)
|
So(m.Size, ShouldEqual, status.Size)
|
||||||
So(m.IsMaster, ShouldEqual, status.IsMaster)
|
So(m.IsMaster, ShouldEqual, status.IsMaster)
|
||||||
So(time.Now().Sub(m.LastUpdate.Time), ShouldBeLessThan, 3*time.Second)
|
So(time.Since(m.LastUpdate.Time), ShouldBeLessThan, 3*time.Second)
|
||||||
So(time.Now().Sub(m.LastStarted.Time), ShouldBeLessThan, 2*time.Second)
|
So(time.Since(m.LastStarted.Time), ShouldBeLessThan, 2*time.Second)
|
||||||
So(time.Now().Sub(m.LastEnded.Time), ShouldBeLessThan, 3*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.Upstream, ShouldEqual, status.Upstream)
|
||||||
So(m.Size, ShouldEqual, "5GB")
|
So(m.Size, ShouldEqual, "5GB")
|
||||||
So(m.IsMaster, ShouldEqual, status.IsMaster)
|
So(m.IsMaster, ShouldEqual, status.IsMaster)
|
||||||
So(time.Now().Sub(m.LastUpdate), ShouldBeLessThan, 3*time.Second)
|
So(time.Since(m.LastUpdate), ShouldBeLessThan, 3*time.Second)
|
||||||
So(time.Now().Sub(m.LastStarted), ShouldBeLessThan, 2*time.Second)
|
So(time.Since(m.LastStarted), ShouldBeLessThan, 2*time.Second)
|
||||||
So(time.Now().Sub(m.LastEnded), ShouldBeLessThan, 3*time.Second)
|
So(time.Since(m.LastEnded), ShouldBeLessThan, 3*time.Second)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
Convey("Update schedule of valid mirrors", func(ctx C) {
|
Convey("Update schedule of valid mirrors", func(ctx C) {
|
||||||
msg := MirrorSchedules{
|
msg := MirrorSchedules{
|
||||||
[]MirrorSchedule{
|
Schedules: []MirrorSchedule{
|
||||||
MirrorSchedule{"arch-sync1", time.Now().Add(time.Minute * 10)},
|
MirrorSchedule{MirrorName: "arch-sync1", NextSchedule: time.Now().Add(time.Minute * 10)},
|
||||||
MirrorSchedule{"arch-sync2", time.Now().Add(time.Minute * 7)},
|
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.Upstream, ShouldEqual, status.Upstream)
|
||||||
So(m.Size, ShouldEqual, status.Size)
|
So(m.Size, ShouldEqual, status.Size)
|
||||||
So(m.IsMaster, ShouldEqual, status.IsMaster)
|
So(m.IsMaster, ShouldEqual, status.IsMaster)
|
||||||
So(time.Now().Sub(m.LastUpdate), ShouldBeGreaterThan, 3*time.Second)
|
So(time.Since(m.LastUpdate), ShouldBeGreaterThan, 3*time.Second)
|
||||||
So(time.Now().Sub(m.LastStarted), ShouldBeGreaterThan, 3*time.Second)
|
So(time.Since(m.LastStarted), ShouldBeGreaterThan, 3*time.Second)
|
||||||
So(time.Now().Sub(m.LastEnded), ShouldBeLessThan, 1*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) {
|
Convey("update schedule of an non-existent worker", func(ctx C) {
|
||||||
invalidWorker := "test_worker2"
|
invalidWorker := "test_worker2"
|
||||||
sch := MirrorSchedules{
|
sch := MirrorSchedules{
|
||||||
[]MirrorSchedule{
|
Schedules: []MirrorSchedule{
|
||||||
MirrorSchedule{"arch-sync1", time.Now().Add(time.Minute * 10)},
|
MirrorSchedule{MirrorName: "arch-sync1", NextSchedule: time.Now().Add(time.Minute * 10)},
|
||||||
MirrorSchedule{"arch-sync2", time.Now().Add(time.Minute * 7)},
|
MirrorSchedule{MirrorName: "arch-sync2", NextSchedule: time.Now().Add(time.Minute * 7)},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
resp, err := PostJSON(fmt.Sprintf("%s/workers/%s/schedules",
|
resp, err := PostJSON(fmt.Sprintf("%s/workers/%s/schedules",
|
||||||
|
@ -127,9 +127,7 @@ func (p *twoStageRsyncProvider) Options(stage int) ([]string, error) {
|
|||||||
if !ok {
|
if !ok {
|
||||||
return nil, errors.New("Invalid Stage 1 Profile")
|
return nil, errors.New("Invalid Stage 1 Profile")
|
||||||
}
|
}
|
||||||
for _, exc := range stage1Profile {
|
options = append(options, stage1Profile...)
|
||||||
options = append(options, exc)
|
|
||||||
}
|
|
||||||
|
|
||||||
} else if stage == 2 {
|
} else if stage == 2 {
|
||||||
options = append(options, p.stage2Options...)
|
options = append(options, p.stage2Options...)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user