镜像自地址
https://github.com/tuna/tunasync.git
已同步 2025-12-06 06:26:46 +00:00
feature(worker): framework of mirror provider
这个提交包含在:
59
worker/provider_test.go
普通文件
59
worker/provider_test.go
普通文件
@@ -0,0 +1,59 @@
|
||||
package worker
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
. "github.com/smartystreets/goconvey/convey"
|
||||
)
|
||||
|
||||
func TestRsyncProvider(t *testing.T) {
|
||||
Convey("Rsync Provider should work", t, func() {
|
||||
|
||||
c := rsyncConfig{
|
||||
name: "tuna",
|
||||
upstreamURL: "rsync://rsync.tuna.moe/tuna/",
|
||||
workingDir: "/srv/mirror/production/tuna",
|
||||
logDir: "/var/log/tunasync",
|
||||
logFile: "tuna.log",
|
||||
useIPv6: true,
|
||||
interval: 600,
|
||||
}
|
||||
|
||||
provider, err := newRsyncProvider(c)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
So(provider.Name(), ShouldEqual, c.name)
|
||||
So(provider.WorkingDir(), ShouldEqual, c.workingDir)
|
||||
So(provider.LogDir(), ShouldEqual, c.logDir)
|
||||
So(provider.LogFile(), ShouldEqual, c.logFile)
|
||||
|
||||
Convey("When entering a context (auto exit)", func() {
|
||||
func() {
|
||||
ctx := provider.EnterContext()
|
||||
defer provider.ExitContext()
|
||||
So(provider.WorkingDir(), ShouldEqual, c.workingDir)
|
||||
newWorkingDir := "/srv/mirror/working/tuna"
|
||||
ctx.Set(_WorkingDirKey, newWorkingDir)
|
||||
So(provider.WorkingDir(), ShouldEqual, newWorkingDir)
|
||||
}()
|
||||
|
||||
Convey("After context is done", func() {
|
||||
So(provider.WorkingDir(), ShouldEqual, c.workingDir)
|
||||
})
|
||||
})
|
||||
|
||||
Convey("When entering a context (manually exit)", func() {
|
||||
ctx := provider.EnterContext()
|
||||
So(provider.WorkingDir(), ShouldEqual, c.workingDir)
|
||||
newWorkingDir := "/srv/mirror/working/tuna"
|
||||
ctx.Set(_WorkingDirKey, newWorkingDir)
|
||||
So(provider.WorkingDir(), ShouldEqual, newWorkingDir)
|
||||
|
||||
Convey("After context is done", func() {
|
||||
provider.ExitContext()
|
||||
So(provider.WorkingDir(), ShouldEqual, c.workingDir)
|
||||
})
|
||||
})
|
||||
|
||||
})
|
||||
}
|
||||
在新工单中引用
屏蔽一个用户