diff --git a/tests/helpers/http.go b/tests/helpers/http.go index 4416d7b7..03207d11 100644 --- a/tests/helpers/http.go +++ b/tests/helpers/http.go @@ -208,6 +208,16 @@ func checkResponseHeaders(t testing.TB, expectedHeaders map[string]string, actua // AssertReportResponsesEqual checks if reports in answer are the same func AssertReportResponsesEqual(t testing.TB, expected, got []byte) { + AssertReportResponsesEqualCustomElementsChecker(t, expected, got, func(t testing.TB, expected []types.RuleOnReport, got []types.RuleOnReport) { + assert.ElementsMatch(t, expected, got) + }) +} + +// AssertReportResponsesEqualCustomElementsChecker checks if reports in answer are the same using custom checker +// for elements +func AssertReportResponsesEqualCustomElementsChecker( + t testing.TB, expected, got []byte, elementsChecker func(testing.TB, []types.RuleOnReport, []types.RuleOnReport), +) { var expectedResponse, gotResponse struct { Status string `json:"status"` Report types.ReportResponse `json:"report"` @@ -239,7 +249,9 @@ func AssertReportResponsesEqual(t testing.TB, expected, got []byte) { len(gotResponse.Report.Report), "length of reports should be equal", ) - assert.ElementsMatch(t, expectedResponse.Report.Report, gotResponse.Report.Report) + if elementsChecker != nil { + elementsChecker(t, expectedResponse.Report.Report, gotResponse.Report.Report) + } } // AssertRuleResponsesEqual checks if rules in answer are the same diff --git a/types/types.go b/types/types.go index c39ded0e..69b72d46 100644 --- a/types/types.go +++ b/types/types.go @@ -50,11 +50,13 @@ type RuleID string // RuleOnReport represents a single (hit) rule of the string encoded report type RuleOnReport struct { - Module RuleID `json:"component"` - ErrorKey ErrorKey `json:"key"` - UserVote UserVote `json:"user_vote"` - Disabled bool `json:"disabled"` - TemplateData interface{} `json:"details"` + Module RuleID `json:"component"` + ErrorKey ErrorKey `json:"key"` + UserVote UserVote `json:"user_vote"` + Disabled bool `json:"disabled"` + DisableFeedback string `json:"disable_feedback"` + DisabledAt Timestamp `json:"disabled_at"` + TemplateData interface{} `json:"details"` } // ReportRules is a helper struct for easy JSON unmarshalling of string encoded report