Skip to content

Commit

Permalink
fix: ensure test for environ fromMap is deterministic (#230)
Browse files Browse the repository at this point in the history
  • Loading branch information
nickatsegment committed Sep 24, 2019
1 parent 40375db commit f581b8e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions environ/environ.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down
3 changes: 3 additions & 0 deletions environ/environ_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package environ

import (
"sort"
"testing"

"github.com/segmentio/chamber/store"
Expand Down Expand Up @@ -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)
})
}
Expand Down

0 comments on commit f581b8e

Please sign in to comment.