Skip to content

Commit 9c99d6b

Browse files
committed
fix confusing matching test
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
1 parent 1000016 commit 9c99d6b

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

pkg/policies/engine/rego/rego_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,18 +341,18 @@ func TestRego_MatchesParameters(t *testing.T) {
341341
Source: regoContent,
342342
}
343343

344-
t.Run("high severity matches medium expectation", func(t *testing.T) {
344+
t.Run("high expectation matches low severity", func(t *testing.T) {
345345
matches, err := r.MatchesParameters(context.TODO(), policy,
346-
map[string]string{"severity": "high"},
347-
map[string]string{"severity": "medium"})
346+
map[string]string{"severity": "low"},
347+
map[string]string{"severity": "high"})
348348
require.NoError(t, err)
349349
assert.True(t, matches)
350350
})
351351

352-
t.Run("low severity does not match high expectation", func(t *testing.T) {
352+
t.Run("medium expectation does not match high severity", func(t *testing.T) {
353353
matches, err := r.MatchesParameters(context.TODO(), policy,
354-
map[string]string{"severity": "low"},
355-
map[string]string{"severity": "high"})
354+
map[string]string{"severity": "high"},
355+
map[string]string{"severity": "medium"})
356356
require.NoError(t, err)
357357
assert.False(t, matches)
358358
})

pkg/policies/engine/rego/testfiles/matches_parameters.rego

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ matches_parameters := result {
1515
eval_idx := severity_index(eval_severity)
1616
expected_idx := severity_index(expected_severity)
1717

18-
# Evaluation severity must be >= expected severity
19-
result := eval_idx >= expected_idx
18+
# Expected severity must be >= evaluation severity
19+
result := expected_idx >= eval_idx
2020
}

0 commit comments

Comments
 (0)