Skip to content

Conversation

aelsabbahy
Copy link
Member

Closes #800

Checklist
  • make test-all (UNIX) passes. CI will also test this
  • unit and/or integration tests are included (if applicable)
  • documentation is changed or added (if applicable)

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

@aelsabbahy aelsabbahy merged commit b98798e into master Sep 14, 2023
@aelsabbahy aelsabbahy deleted the better_error_msgs branch September 14, 2023 17:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Package Semver-Constraint Check - Printing warnings condition not met
1 participant