Skip to content

Commit

Permalink
chore: explicitly test go pseudoversion (#1522)
Browse files Browse the repository at this point in the history
The logic in the fuzzy version constraint works for go pseudoversions,
because they happen be in string sort order. Add unit tests to ensure
this coincidental behavior is not lost.

Signed-off-by: Will Murphy <[email protected]>
  • Loading branch information
willmurphyscode authored Sep 26, 2023
1 parent 0085ddb commit 377ea3e
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions grype/version/fuzzy_constraint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,24 @@ func TestFuzzyConstraintSatisfaction(t *testing.T) {
constraint: "> 1.1.1-a",
satisfied: true,
},
{
name: "go pseudoversion vulnerable: version is less, want less",
version: "0.0.0-20230716120725-531d2d74bc12",
constraint: "<0.0.0-20230922105210-14b16010c2ee",
satisfied: true,
},
{
name: "go pseudoversion not vulnerable: same version but constraint is less",
version: "0.0.0-20230922105210-14b16010c2ee",
constraint: "<0.0.0-20230922105210-14b16010c2ee",
satisfied: false,
},
{
name: "go pseudoversion not vulnerable: greater version",
version: "0.0.0-20230922112808-5421fefb8386",
constraint: "<0.0.0-20230922105210-14b16010c2ee",
satisfied: false,
},
}

for _, test := range tests {
Expand Down

0 comments on commit 377ea3e

Please sign in to comment.