From f581b8ea9c81d438e25494b86726a951ada48560 Mon Sep 17 00:00:00 2001 From: Nick Irvine Date: Mon, 23 Sep 2019 18:49:39 -0700 Subject: [PATCH] fix: ensure test for environ fromMap is deterministic (#230) --- environ/environ.go | 1 + environ/environ_test.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/environ/environ.go b/environ/environ.go index 95de18af..3357d38c 100644 --- a/environ/environ.go +++ b/environ/environ.go @@ -53,6 +53,7 @@ func (e *Environ) Map() map[string]string { return ret } +// fromMap returns an Environ based on m. Order is arbitrary. func fromMap(m map[string]string) Environ { e := make([]string, 0, len(m)) diff --git a/environ/environ_test.go b/environ/environ_test.go index 1ba0aee2..2000e794 100644 --- a/environ/environ_test.go +++ b/environ/environ_test.go @@ -1,6 +1,7 @@ package environ import ( + "sort" "testing" "github.com/segmentio/chamber/store" @@ -177,6 +178,8 @@ func TestFromMap(t *testing.T) { for _, tc := range cases { t.Run(tc.name, func(t *testing.T) { e := fromMap(tc.in) + // maps order is non-deterministic + sort.Strings(e) assert.EqualValues(t, e, tc.out) }) }