Skip to content

Commit

Permalink
feat: expose key value map (#31)
Browse files Browse the repository at this point in the history
This commit exposes the internal key value map using a new method
GetAllValues which returns the map.

Closes #19
  • Loading branch information
rhnvrm authored Feb 16, 2021
1 parent 0c7de78 commit 325d6b2
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
5 changes: 5 additions & 0 deletions parameter.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,8 @@ func (p *Parameters) getKeyValueMap() map[string]string {
}
return keyValue
}

// GetAllValues returns a map with all the keys and values in the store.
func (p *Parameters) GetAllValues() map[string]string {
return p.getKeyValueMap()
}
29 changes: 29 additions & 0 deletions parameter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,35 @@ func TestParameters_Read(t *testing.T) {
}
}

func TestParameters_GetAllValues(t *testing.T) {
tests := []struct {
name string
basePath string
parameters map[string]*Parameter
}{
{
name: "GetAllValues default map",
basePath: "/my-service/dev/",
parameters: getParametersMap(),
},
{
name: "GetAllValues random map",
basePath: "/my-service/dev/",
parameters: getRandomParametersMap(1000, 10),
},
}
for _, test := range tests {
t.Run(test.name, func(t *testing.T) {
parameter := NewParameters(test.basePath, test.parameters)

mp := parameter.GetAllValues()
if len(mp) != len(test.parameters) {
t.Errorf(`Unexpected value: got %v, expected %v`, len(mp), len(test.parameters))
}
})
}
}

func getParametersMap() map[string]*Parameter {
return map[string]*Parameter{
"/my-service/dev/DB_PASSWORD": {Value: param1.Value},
Expand Down

0 comments on commit 325d6b2

Please sign in to comment.