Unit tests/spec: Invalid inventoryfile structure can cause hard to debug error
Open
Nobody has claimed this yet.
Bug
- Dominant language
- Ruby
- Stars
- 558
- Forks
- 224
- Avg merge
- 1h 4m
- Merged PRs (30d)
- 1
Description
Describe the Bug
Same as #2430 but for unit tests. Accidentally loaded an inventory yaml file without a groups key:
- name: somegroup
targets:
- alias: somealias
name: somename
uri: some.uri
running a unit test using it returns
... instead of raising Puppet::PreformattedError(Evaluation Error: Error while evaluating a Function Call, undefined method `key?' for [{"name"=>"somegroup", "targets"=>[{"alias"=>"somealias", "name"=>"somename", "uri"=>"some.uri"}]}]:Array
Expected Behavior
Print a clear error that the inventory structure is invalid
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Compare this unit-test case with issue #2430 and trace the inventory YAML loading path used by unit tests. Reproduce the missing groups key structure, then add coverage showing that it raises a clear invalid-inventory error instead of the current key? failure.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100