mirror of
https://github.com/tuna/tunasync.git
synced 2025-06-15 05:52:43 +00:00
refactor(worker): export worker's LoadConfig
This commit is contained in:
parent
0dcd89da31
commit
f8151e689f
@ -76,7 +76,8 @@ type mirrorConfig struct {
|
|||||||
Stage1Profile string `toml:"stage1_profile"`
|
Stage1Profile string `toml:"stage1_profile"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func loadConfig(cfgFile string) (*Config, error) {
|
// LoadConfig loads configuration
|
||||||
|
func LoadConfig(cfgFile string) (*Config, error) {
|
||||||
if _, err := os.Stat(cfgFile); err != nil {
|
if _, err := os.Stat(cfgFile); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -54,7 +54,7 @@ exclude_file = "/etc/tunasync.d/fedora-exclude.txt"
|
|||||||
`
|
`
|
||||||
|
|
||||||
Convey("When giving invalid file", t, func() {
|
Convey("When giving invalid file", t, func() {
|
||||||
cfg, err := loadConfig("/path/to/invalid/file")
|
cfg, err := LoadConfig("/path/to/invalid/file")
|
||||||
So(err, ShouldNotBeNil)
|
So(err, ShouldNotBeNil)
|
||||||
So(cfg, ShouldBeNil)
|
So(cfg, ShouldBeNil)
|
||||||
})
|
})
|
||||||
@ -68,7 +68,7 @@ exclude_file = "/etc/tunasync.d/fedora-exclude.txt"
|
|||||||
So(err, ShouldEqual, nil)
|
So(err, ShouldEqual, nil)
|
||||||
defer tmpfile.Close()
|
defer tmpfile.Close()
|
||||||
|
|
||||||
cfg, err := loadConfig(tmpfile.Name())
|
cfg, err := LoadConfig(tmpfile.Name())
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
So(cfg.Global.Name, ShouldEqual, "test_worker")
|
So(cfg.Global.Name, ShouldEqual, "test_worker")
|
||||||
So(cfg.Global.Interval, ShouldEqual, 240)
|
So(cfg.Global.Interval, ShouldEqual, 240)
|
||||||
@ -107,7 +107,7 @@ exclude_file = "/etc/tunasync.d/fedora-exclude.txt"
|
|||||||
So(err, ShouldEqual, nil)
|
So(err, ShouldEqual, nil)
|
||||||
defer tmpfile.Close()
|
defer tmpfile.Close()
|
||||||
|
|
||||||
cfg, err := loadConfig(tmpfile.Name())
|
cfg, err := LoadConfig(tmpfile.Name())
|
||||||
So(err, ShouldBeNil)
|
So(err, ShouldBeNil)
|
||||||
|
|
||||||
w := &Worker{
|
w := &Worker{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user