Skip to content

Commit 726af59

Browse files
committed
refactor: remove unused exported functions from config
1 parent 918b638 commit 726af59

File tree

2 files changed

+1
-33
lines changed

2 files changed

+1
-33
lines changed

config/config.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -212,17 +212,7 @@ func BindConfigToFlags(v *viper.Viper, cmd *cobra.Command, config any) error {
212212
return nil
213213
}
214214

215-
// GenerateFlagSet is exported for testing.
216-
func GenerateFlagSet(config any) (*pflag.FlagSet, error) {
217-
return generateFlagSet(config)
218-
}
219-
220-
// UnmarshalIntoStruct is exported for testing.
221-
func UnmarshalIntoStruct(v *viper.Viper, cfg any) func() {
222-
return unmarshalIntoStruct(v, cfg)
223-
}
224-
225-
// unmarshalIntoStruct returns a function that unmarshals viper config into cfg and panics on error.
215+
// unmarshalIntoStruct returns a function that unmarshal viper config into cfg and panics on error.
226216
func unmarshalIntoStruct(v *viper.Viper, cfg any) func() {
227217
return func() {
228218
if err := v.Unmarshal(cfg); err != nil {

config/config_test.go

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -177,25 +177,3 @@ func TestGenerateFlagSetUnsupportedType(t *testing.T) {
177177
err := config.BindConfigToFlags(viper.New(), &cobra.Command{}, &testStruct)
178178
assert.Error(t, err)
179179
}
180-
181-
func TestGenerateFlagSetInvalidStruct(t *testing.T) {
182-
notStruct := 123
183-
_, err := config.GenerateFlagSet(notStruct)
184-
assert.Error(t, err)
185-
}
186-
187-
func TestUnmarshalIntoStructPanic(t *testing.T) {
188-
v := viper.New()
189-
cfg := struct {
190-
InvalidField int `mapstructure:"invalid-field"`
191-
}{}
192-
// Set a string value to cause unmarshal error for int field
193-
v.Set("invalid-field", "not-an-int")
194-
defer func() {
195-
if r := recover(); r == nil {
196-
t.Errorf("expected panic but did not panic")
197-
}
198-
}()
199-
unmarshal := config.UnmarshalIntoStruct(v, &cfg)
200-
unmarshal()
201-
}

0 commit comments

Comments
 (0)