From db83066e9ac4d30b130c8393d5df91e93d316e71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B0=B7=E6=BA=AA?= Date: Mon, 15 Mar 2021 18:03:10 +0800 Subject: [PATCH] fix: s3 config was not exported correctly (#89) * Update dependency.go * test: add testcase for config export --- ots3/dependency.go | 4 +++- ots3/dependency_test.go | 15 +++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/ots3/dependency.go b/ots3/dependency.go index d788bff5..b707d1b1 100644 --- a/ots3/dependency.go +++ b/ots3/dependency.go @@ -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 diff --git a/ots3/dependency_test.go b/ots3/dependency_test.go index 7724673d..fbd79957 100644 --- a/ots3/dependency_test.go +++ b/ots3/dependency_test.go @@ -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" ) @@ -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) + }) }