Skip to content

Commit

Permalink
Merge branch 'main' into lovro/paramgen-ignore-tools
Browse files Browse the repository at this point in the history
  • Loading branch information
lovromazgon authored Apr 17, 2024
2 parents 3944d16 + a77201a commit 990f491
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
2 changes: 1 addition & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func (c Config) Sanitize() Config {
func (c Config) ApplyDefaults(params Parameters) Config {
for key, param := range params {
for _, key := range c.getKeysForParameter(key) {
if strings.TrimSpace(c[key]) == "" {
if strings.TrimSpace(c[key]) == "" && param.Default != "" {
c[key] = param.Default
}
}
Expand Down
4 changes: 1 addition & 3 deletions config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ func TestConfig_ApplyDefaults(t *testing.T) {
want: Config{
"limit": "-1",
"foo.0.param1": "custom",
"foo.0.param2": "",
// empty defaults are not populated
},
}, {
name: "multiple dynamic params",
Expand All @@ -634,11 +634,9 @@ func TestConfig_ApplyDefaults(t *testing.T) {
want: Config{
"limit": "-1",
"foo.0.param1": "parameter",
"foo.0.param2": "",
"foo.1.param1": "foo",
"foo.1.param2": "custom",
"foo.2.param1": "foo",
"foo.2.param2": "",
"foo.2.does-not-exist": "unrecognized key still triggers creation of defaults",
},
}}
Expand Down

0 comments on commit 990f491

Please sign in to comment.