Closed sfc-gh-ssudakovich closed 10 months ago
The test is reporting thaht it found version 3.8.1 which does not meet the constraint >3.8.2
The reason it's an array is because there may be multiple versions installed of the same packcage.
Some examples (using latest version of goss):
package:
td-agent:
installed: true
versions:
and:
- have-len: 1
- contain-element:
semver-constraint: ">3.8.2"
$ goss v
F
Failures/Skipped:
Matching: td-agent: matches:
Expected
["3.8.1"]
to contain element matching
{"semver-constraint":">3.8.2"}
Total Duration: 0.000s
Count: 1, Failed: 1, Skipped: 0
If I change it to this:
matching:
td-agent:
content:
- 3.8.1
- 3.8.0
matches:
and:
- have-len: 2
- contain-element:
semver-constraint: ">3.8.2"
It'll still fail with:
$ goss v
F
Failures/Skipped:
Matching: td-agent: matches:
Expected
["3.8.1","3.8.0"]
to contain element matching
{"semver-constraint":">3.8.2"}
Total Duration: 0.000s
Count: 1, Failed: 1, Skipped: 0
However, the following will pass, since at least one element matches.
matching:
td-agent:
content:
- 3.8.1
- 3.8.3
matches:
and:
- have-len: 2
- contain-element:
semver-constraint: ">3.8.2"
Without the contain-element, all elements must match:
matching:
td-agent:
content:
- 3.8.4
- 3.8.3
matches:
and:
- have-len: 2
- semver-constraint: ">3.8.2"
I am trying to make sure that a package is installed and the version is at least X.Y.Z or higher. For the sake of the example, let's say the package is
td-agent
and the minimal version is3.8.2
. What I came up with using the manual is thisThat results in
I feel like it is trying to compare an array to a matcher but I am not sure. Any suggestions?