bolt icon indicating copy to clipboard operation
bolt copied to clipboard

Unit tests/spec: Invalid inventoryfile structure can cause hard to debug error

Open dionysius opened this issue 1 year ago • 0 comments

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

dionysius avatar Sep 06 '24 23:09 dionysius