From 485bc668bff2dd3523b82d77c1a0ffb0af958c76 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 10 Jul 2014 13:32:16 -0700 Subject: [PATCH] flatmap: deterministic tests --- flatmap/map_test.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/flatmap/map_test.go b/flatmap/map_test.go index bb0f44f29..1021ecf1d 100644 --- a/flatmap/map_test.go +++ b/flatmap/map_test.go @@ -2,6 +2,7 @@ package flatmap import ( "reflect" + "sort" "testing" ) @@ -36,14 +37,18 @@ func TestMapKeys(t *testing.T) { "bar.0.baz": "bar", }, Output: []string{ - "foo", "bar", + "foo", }, }, } for _, tc := range cases { actual := Map(tc.Input).Keys() + + // Sort so we have a consistent view of the output + sort.Strings(actual) + if !reflect.DeepEqual(actual, tc.Output) { t.Fatalf("input: %#v\n\nbad: %#v", tc.Input, actual) }