File size: 1,044 Bytes
6380833 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | package models
import (
"testing"
"github.com/stretchr/testify/require"
)
// FIXME: dependency directions are messed up due to using same lexical package name across tests and package
func RequireValidationIssuesMatch(t *testing.T, expected ValidationIssues, actual ValidationIssues) {
t.Helper()
expCopy := expected.Clone()
actCopy := actual.Clone()
require.Len(t, actCopy, len(expCopy), "issue count must match")
for i := range actCopy {
actualField := actCopy[i].Field()
expectedField := expCopy[i].Field()
require.Equal(t, expectedField.String(), actualField.String(), "[code = %s] field string must match at index %d", actual[i].Code(), i)
require.Equal(t, expectedField.JSONPath(), actualField.JSONPath(), "[code = %s] field json path must match at index %d", actual[i].Code(), i)
// Do not strip attributes; compare full set, including status code
actCopy[i].field = nil
expCopy[i].field = nil
actCopy[i].wraps = nil
expCopy[i].wraps = nil
}
require.Equalf(t, expCopy, actCopy, "issues must match")
}
|