This is an automated email from the ASF dual-hosted git repository. dewrich pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-trafficcontrol.git
commit fa0df76fa98e22e1139cb0bb5f223ff43d1d6870 Author: Dan Kirkwood <dang...@apache.org> AuthorDate: Wed Feb 28 13:32:19 2018 -0700 added SortErrors to test package --- traffic_ops/traffic_ops_golang/test/helpers.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/traffic_ops/traffic_ops_golang/test/helpers.go b/traffic_ops/traffic_ops_golang/test/helpers.go index b550fab..4b6ef9c 100644 --- a/traffic_ops/traffic_ops_golang/test/helpers.go +++ b/traffic_ops/traffic_ops_golang/test/helpers.go @@ -21,6 +21,7 @@ package test import ( "reflect" + "sort" "strings" ) @@ -40,3 +41,22 @@ func ColsFromStructByTag(tagName string, thing interface{}) []string { } return cols } + +// sortableErrors provides ordering a list of errors for easier comparison with an expected list +type sortableErrors []error + +func (s sortableErrors) Len() int { + return len(s) +} +func (s sortableErrors) Swap(i, j int) { + s[i], s[j] = s[j], s[i] +} +func (s sortableErrors) Less(i, j int) bool { + return s[i].Error() < s[j].Error() +} + +// SortErrors sorts the list of errors lexically +func SortErrors(p []error) []error { + sort.Sort(sortableErrors(p)) + return p +} -- To stop receiving notification emails like this one, please contact dewr...@apache.org.