Skip to content

Commit

Permalink
Add ability for unknown function-level configuration settings to be a…
Browse files Browse the repository at this point in the history
…rrays / vectors
  • Loading branch information
ryanblock committed Oct 23, 2023
1 parent dcf5e6a commit a372953
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 4 deletions.
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

---

## [3.6.2] 2023-10-23

### Added

- Added ability for unknown function-level configuration settings to be arrays / vectors

---

## [3.6.1] 2023-08-15

### Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/config/_upsert.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ module.exports = function upsertProps (config, newConfig) {
policies = policies.concat(value)
}
else {
props[name] = value[0]
props[name] = value.length === 1 ? value[0] : value
}
}

Expand Down
25 changes: 22 additions & 3 deletions test/unit/src/config/_upsert-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,12 +453,31 @@ runtime python
})

test('Individual setting upsert: something unknown', t => {
t.plan(2)
let value = 'mysterious'
t.plan(6)
let result, value

value = 'mysterious'
let { aws: idk } = parse(`@aws
idk ${value}
`)
let result = upsert(defaults, idk)
result = upsert(defaults, idk)
t.notOk(defaults.idk, 'Testing property not already present in the default')
t.equal(result.idk, value, 'Properly upserted unknown setting')

value = [ 'foo', 'bar' ]
let { aws: arr } = parse(`@aws
arr
${value[0]}
${value[1]}
`)
result = upsert(defaults, arr)
t.notOk(defaults.arr, 'Testing property not already present in the default')
t.deepEqual(result.arr, value, 'Properly upserted unknown array setting')

let { aws: inlineArr } = parse(`@aws
arr ${value[0]} ${value[1]}
`)
result = upsert(defaults, inlineArr)
t.notOk(defaults.arr, 'Testing property not already present in the default')
t.deepEqual(result.arr, value, 'Properly upserted unknown inline array setting')
})

0 comments on commit a372953

Please sign in to comment.