-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Tyler Gillson <[email protected]>
- Loading branch information
1 parent
ca18e2b
commit 85e012c
Showing
1 changed file
with
36 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package util | ||
|
||
import ( | ||
"errors" | ||
"reflect" | ||
"testing" | ||
|
||
"github.com/spectrocloud-labs/validator/pkg/types" | ||
) | ||
|
||
func CheckTestCase(t *testing.T, res *types.ValidationRuleResult, expectedResult types.ValidationRuleResult, err, expectedError error) { | ||
if !reflect.DeepEqual(res.State, expectedResult.State) { | ||
t.Errorf("expected state (%+v), got (%+v)", expectedResult.State, res.State) | ||
} | ||
if !reflect.DeepEqual(res.Condition.ValidationType, expectedResult.Condition.ValidationType) { | ||
t.Errorf("expected validation type (%s), got (%s)", expectedResult.Condition.ValidationType, res.Condition.ValidationType) | ||
} | ||
if !reflect.DeepEqual(res.Condition.ValidationRule, expectedResult.Condition.ValidationRule) { | ||
t.Errorf("expected validation rule (%s), got (%s)", expectedResult.Condition.ValidationRule, res.Condition.ValidationRule) | ||
} | ||
if !reflect.DeepEqual(res.Condition.Message, expectedResult.Condition.Message) { | ||
t.Errorf("expected message (%s), got (%s)", expectedResult.Condition.Message, res.Condition.Message) | ||
} | ||
if !reflect.DeepEqual(res.Condition.Details, expectedResult.Condition.Details) { | ||
t.Errorf("expected details (%s), got (%s)", expectedResult.Condition.Details, res.Condition.Details) | ||
} | ||
if !reflect.DeepEqual(res.Condition.Failures, expectedResult.Condition.Failures) { | ||
t.Errorf("expected failures (%s), got (%s)", expectedResult.Condition.Failures, res.Condition.Failures) | ||
} | ||
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) | ||
} | ||
} |