goss-org / goss

Quick and Easy server testing/validation
https://goss.rocks
Apache License 2.0
5.5k stars 470 forks source link

Changed: Reworded syntax error messages to be clearer #838

Closed aelsabbahy closed 9 months ago

aelsabbahy commented 10 months ago

Closes #800

Checklist

Description of change

Added syntax checking for when multiple keys are provided. Improved syntax error messages in general.

Example of new errors:

$ cat goss.yaml 
matching:
  example:
   content: ['1.14.1']
   matches:
     and:
       - have-len: 1
         and:
           matches:
             - semver-constraint: '<1.14.0'
$ goss v
F

Failures/Skipped:

Matching: example: matches:
Error
    Syntax Error: Invalid matcher configuration. At a given nesting level, only one matcher is allowed. Found multiple matchers: ["have-len" "and"]

Total Duration: 0.000s
Count: 1, Failed: 1, Skipped: 0
$ cat goss.yaml 
matching:
  example:
   content: ['1.14.1']
   matches:
     and:
       - have-len: 1
       - and:
           matches:
             - semver-constraint: '<1.14.0'
$ goss v
F

Failures/Skipped:

Matching: example: matches:
Error
    Syntax Error: Invalid 'and' argument. Expected array value, but received: map["matches":[map["semver-constraint":"<1.14.0"]]]

Total Duration: 0.000s
Count: 1, Failed: 1, Skipped: 0