Skip to content

Commit fb3609d

Browse files
committed
fix tests
Signed-off-by: Sylwester Piskozub <sylwesterpiskozub@gmail.com>
1 parent febf626 commit fb3609d

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

pkg/policies/engine/rego/rego_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,31 +392,31 @@ func TestRego_MatchesEvaluation(t *testing.T) {
392392
Source: regoContent,
393393
}
394394

395-
t.Run("evaluation with violations and high severity matches", func(t *testing.T) {
395+
t.Run("evaluation with violations and high severity does not match", func(t *testing.T) {
396396
violations := []string{"test violation"}
397397
evaluationParams := map[string]string{"severity": "high"}
398398
matches, err := r.MatchesEvaluation(context.TODO(), policy, violations, evaluationParams)
399399
require.NoError(t, err)
400-
assert.True(t, matches)
400+
assert.False(t, matches)
401401
})
402402

403-
t.Run("evaluation without violations does not match", func(t *testing.T) {
403+
t.Run("evaluation without violations does matches", func(t *testing.T) {
404404
violations := []string{}
405405
evaluationParams := map[string]string{"severity": "high"}
406406
matches, err := r.MatchesEvaluation(context.TODO(), policy, violations, evaluationParams)
407407
require.NoError(t, err)
408408
assert.False(t, matches)
409409
})
410410

411-
t.Run("evaluation with violations but wrong severity does not match", func(t *testing.T) {
411+
t.Run("evaluation with violations but wrong severity does match", func(t *testing.T) {
412412
violations := []string{"test violation"}
413413
evaluationParams := map[string]string{"severity": "low"}
414414
matches, err := r.MatchesEvaluation(context.TODO(), policy, violations, evaluationParams)
415415
require.NoError(t, err)
416416
assert.False(t, matches)
417417
})
418418

419-
t.Run("nil evaluation does not match", func(t *testing.T) {
419+
t.Run("nil evaluation matches", func(t *testing.T) {
420420
evaluationParams := map[string]string{"severity": "high"}
421421
matches, err := r.MatchesEvaluation(context.TODO(), policy, nil, evaluationParams)
422422
require.NoError(t, err)
Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package test_matches_evaluation
22

3-
matches_evaluation := result {
3+
default matches_evaluation := true
4+
5+
matches_evaluation := false if {
46
# Check if the evaluation contains violations
57
count(input.violations) > 0
68

79
# Check if we have the expected parameter
810
input.expected_args.severity == "high"
9-
10-
# If both conditions are met, return true
11-
result := true
1211
}

0 commit comments

Comments
 (0)