have unit-enabled test fail on non-existing unit
Closes #1708 (closed)
This MR ensures that the unit-enabled test in sylva-units fails when called on an undefined unit.
I could have made the choice of not failing in such a case, and return "not enabled", but this would have left room for typos leading to obscure errors.
What is changed:
- The code was wrongly returning true for an undefined unit, if
units_enabled_defaultwas true (case ofmanagement.values.yaml), because in that case it was returningunits_enabled_default... this is fixed - a
failwith an error message is now done if no unit definition is found - the rest is a code flow and indentation change without behavior change: we now first test the error case, and eventually fail, and in the normal case does we do not need to be in an
if
Edited by Thomas Morin