Skip to content

Commit

Permalink
Remove MustLoad method.
Browse files Browse the repository at this point in the history
  • Loading branch information
efritz committed Jan 3, 2021
1 parent 0171e09 commit f44a48e
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 152 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
### Removed

- Removed mocks package. [#9](https://github.com/go-nacelle/config/pull/9)
- Removed `MustLoad` from `Config` interface. [#11](https://github.com/go-nacelle/config/pull/11)

### Changed

Expand Down
10 changes: 0 additions & 10 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ type Config interface {
// the PostLoadConfig interface.
PostLoad(interface{}) error

// MustInject calls Injects and panics on error.
MustLoad(interface{}, ...TagModifier)

// Assets returns a list of names of assets that compose the
// underlying sourcer. This can be a list of matched files that are
// read, or a token that denotes a fixed source.
Expand Down Expand Up @@ -107,13 +104,6 @@ func (c *config) PostLoad(target interface{}) error {
return nil
}

// MustLoad calls Load and panics on error.
func (c *config) MustLoad(target interface{}, modifiers ...TagModifier) {
if err := c.Load(target, modifiers...); err != nil {
panic(err.Error())
}
}

func (c *config) Assets() []string {
return c.sourcer.Assets()
}
Expand Down
6 changes: 0 additions & 6 deletions logging_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,6 @@ func (c *loggingConfig) Load(target interface{}, modifiers ...TagModifier) error
return nil
}

func (c *loggingConfig) MustLoad(target interface{}, modifiers ...TagModifier) {
if err := c.Load(target, modifiers...); err != nil {
panic(err.Error())
}
}

func (c *loggingConfig) dumpSource() error {
chunk := map[string]interface{}{}
for key, value := range c.Config.Dump() {
Expand Down
16 changes: 0 additions & 16 deletions logging_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,3 @@ func TestLoggingConfigBadMaskTag(t *testing.T) {

assert.EqualError(t, lc.Load(chunk), "failed to serialize config (field 'X' has an invalid mask tag)")
}

func TestLoggingConfigMustLoadLogs(t *testing.T) {
type C struct {
X string `env:"x"`
Y int `env:"y"`
Z []string `env:"w" display:"Q"`
}

config := NewMockConfig()
logger := NewMockLogger()
lc := NewLoggingConfig(config, logger, nil)
chunk := &C{}

lc.MustLoad(chunk)
mockassert.CalledOnce(t, logger.PrintfFunc)
}
120 changes: 0 additions & 120 deletions mock_config_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit f44a48e

Please sign in to comment.