Skip to content

Commit

Permalink
test: better error validation in CheckTestCase
Browse files Browse the repository at this point in the history
Signed-off-by: Tyler Gillson <tyler.gillson@gmail.com>
  • Loading branch information
TylerGillson committed Mar 12, 2024
1 parent 85e012c commit fc351f3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/util/test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package util

import (
"errors"
"reflect"
"testing"

Expand Down Expand Up @@ -30,7 +29,12 @@ func CheckTestCase(t *testing.T, res *types.ValidationRuleResult, expectedResult
if !reflect.DeepEqual(res.Condition.Status, expectedResult.Condition.Status) {
t.Errorf("expected status (%s), got (%s)", expectedResult.Condition.Status, res.Condition.Status)
}
if !errors.Is(err, expectedError) {
t.Errorf("expected error (%v), got (%v)", expectedError, err)
if expectedError != nil {
if err == nil {
t.Errorf("expected error (%v), got nil", expectedError)
}
if !reflect.DeepEqual(err.Error(), expectedError.Error()) {
t.Errorf("expected error (%v), got (%v)", expectedError, err)
}
}
}

0 comments on commit fc351f3

Please sign in to comment.