1
0
镜像自地址 https://github.com/tuna/tunasync.git 已同步 2025-12-06 06:26:46 +00:00

feature(worker): framework of mirror provider

这个提交包含在:
bigeagle
2016-04-21 21:57:32 +08:00
父节点 f95a0f9a6f
当前提交 44af0d5e62
共有 4 个文件被更改,包括 193 次插入5 次删除

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)
})
})
})
}