Skip to content

Commit

Permalink
fix: config Load
Browse files Browse the repository at this point in the history
  • Loading branch information
moocss committed Aug 21, 2024
1 parent 909380a commit 51be1d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
9 changes: 1 addition & 8 deletions conf/wraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,10 @@ type Config struct {
}

func New(files []Source) *Config {
conf := &Config{
return &Config{
files: files,
cached: &sync.Map{},
}

err := conf.Load()
if err != nil {
return nil
}

return conf
}

func (c *Config) Watch(fn func()) {
Expand Down
6 changes: 5 additions & 1 deletion conf/wraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ func TestLoad(t *testing.T) {
c := conf.New([]conf.Source{
file.NewSource("testdata/dev.yaml"),
})
err := c.Load()

assert.NoError(t, err)

assert.NotNil(t, c)

err := c.File("dev").UnmarshalKey("db", &db)
err = c.File("dev").UnmarshalKey("db", &db)
if err != nil {
t.Fatalf("unmarshal key error: %v", err)
}
Expand Down

0 comments on commit 51be1d3

Please sign in to comment.