Skip to content

Commit

Permalink
Override provider in value for group provider
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexandr Samylkin committed Mar 13, 2017
1 parent 5653f52 commit 18a7168
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/provider_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ func (p providerGroup) Get(key string) Value {
// here we add a new root, which defines the "scope" at which
// PopulateStructs will look for values.
cv.root = p
cv.provider = p
return cv
}

Expand Down
13 changes: 13 additions & 0 deletions config/provider_group_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,19 @@ func TestScope_WithGetFromValue(t *testing.T) {
require.False(t, fx.Get("fx").HasValue())
}

func TestProviderGroupScopingValue(t *testing.T) {
t.Parallel()
fst := []byte(`
logging:`)

snd := []byte(`
logging:
enabled: true
`)
pg := NewProviderGroup("group", NewYAMLProviderFromBytes(snd), NewYAMLProviderFromBytes(fst))
assert.True(t, pg.Get("logging").Get("enabled").AsBool())
}

type mockDynamicProvider struct {
data map[string]interface{}
callBacks map[string]ChangeCallback
Expand Down

0 comments on commit 18a7168

Please sign in to comment.