Closed Raghuchn closed 9 months ago
Tried the below it give me success, but the test case should have failed, as the version condition should not be met
[goss_validate]$ nginx -v
nginx version: nginx/1.14.1
[goss_validate]$ cat goss_packages.yaml
package:
nginx:
installed: true
versions:
and:
- have-len: 1
and:
matches:
semver-constraint: '<1.13.0'
Test Result:
Package: nginx: installed: matches expectation: [true] Package: nginx: version: matches expectation: []
Thanks!!
Hello, adding a note here in case someone runs into the same issue.
This looks like a typo in the test file, here's an example reproducing the error:
matching:
example:
content: ['1.14.1']
matches:
and:
- have-len: 1
and:
matches:
semver-constraint: '<1.13.0'
The correct syntax is:
matching:
example:
content: ['1.14.1']
matches:
and:
- have-len: 1
- semver-constraint: '<1.13.0'
output:
$ goss v
F
Failures/Skipped:
Matching: example: matches:
Expected
["1.14.1"]
to satisfy semver constraint
"<1.13.0"
Total Duration: 0.000s
Count: 1, Failed: 1, Skipped: 0
v0.4.2 is released with better error messages on syntax errors.
Thank you for reporting this, goss error messages are improved because of this issue!
Hello,
Have a requirement when version condition is not met using semver-constraints, how do i print an desired warning message.
Also, is it possible for the goss tool to continue with the rest of the commands after printing the warning.
package: ngin: installed: true versions: and:
Example: want to print a o/p like
WARNING invalid semver version bad: no major version found
Hello,
I am trying to use the semver-constraint for package check with the below format and it doesn't provide the intended output.
package: nginx: installed: true versions: and: -have-len: 1 -contain-element: semver-constraint: ">=1.14.1"
Error Thrown-
Error: Matcher expected array, got: map[%!t(string=-contain-element):map[%!t(string=matches):map[%!t(string=semver-constraint):%!t(string=>=1.14.1)]] %!t(string=-have-len):%!t(int=1)]
Any suggestion/help on how this condition needs to be handled.
Thanks in Advance!!