Skip to content

Commit

Permalink
fix: s3 config was not exported correctly (#89)
Browse files Browse the repository at this point in the history
* Update dependency.go

* test: add testcase for config export
  • Loading branch information
Reasno authored Mar 15, 2021
1 parent dde8e94 commit db83066
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion ots3/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,9 @@ func provideManager(maker Maker) (managerOut, error) {
}

type configOut struct {
Config []config.ExportedConfig
di.Out

Config []config.ExportedConfig `group:"config,flatten"`
}

// provideConfig exports the default s3 configuration
Expand Down
15 changes: 13 additions & 2 deletions ots3/dependency_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package ots3

import (
"github.com/DoNewsCode/core"
"github.com/DoNewsCode/core/config"
"github.com/DoNewsCode/core/di"
"github.com/stretchr/testify/assert"
"testing"
)
Expand All @@ -22,7 +24,16 @@ func TestNewUploadManagerFactory(t *testing.T) {
assert.NotNil(t, alt)
}

type exportedConfig struct {
di.In

Conf []config.ExportedConfig `group:"config"`
}

func TestProvideConfigs(t *testing.T) {
c := provideConfig()
assert.NotEmpty(t, c.Config)
c := core.New()
c.Provide(di.Deps{provideConfig})
c.Invoke(func(e exportedConfig) {
assert.Equal(t, provideConfig().Config, e.Conf)
})
}

0 comments on commit db83066

Please sign in to comment.