Add a test that checks if reports with data round-trip

Previously the only roundtrip test was for an empty report.
This test has fake data similar to that found in real reports.
'Metrics' does not round-trip exactly, so a DeepEqual workaround is
added for that.
This commit is contained in:
Bryan Boreham
2018-02-26 10:52:50 +00:00
parent 6593720472
commit f44f8806cd
4 changed files with 63 additions and 2 deletions
+5
View File
@@ -146,6 +146,11 @@ func structEq(v1, v2 reflect.Value, visited map[visit]bool, depth int) bool {
if v1.Type().Field(i).Tag.Get("deepequal") == "skip" {
continue
}
if v1.Type().Field(i).Tag.Get("deepequal") == "nil==empty" {
if v1.Field(i).IsNil() && v2.Field(i).Len() == 0 || v2.Field(i).IsNil() && v1.Field(i).Len() == 0 {
continue
}
}
if !deepValueEqual(v1.Field(i), v2.Field(i), visited, depth+1) {
return false
}