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
2017-03-27 13:44:31 +00:00
parent 46c5fca7ce
commit 238ee36e34
4 changed files with 64 additions and 2 deletions

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
}