From 3110ecd6657cb211bd18ddd1ce2ea2eb1c980380 Mon Sep 17 00:00:00 2001 From: equanox Date: Thu, 29 Dec 2022 11:59:38 +0100 Subject: [PATCH] fix envutil tests --- pkg/envutil/envhash.go | 7 +++++++ pkg/envutil/envutil.go | 2 -- pkg/envutil/envutil_test.go | 6 +++++- pkg/envutil/store.go | 7 +++++++ 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 pkg/envutil/envhash.go create mode 100644 pkg/envutil/store.go diff --git a/pkg/envutil/envhash.go b/pkg/envutil/envhash.go new file mode 100644 index 00000000..39e26058 --- /dev/null +++ b/pkg/envutil/envhash.go @@ -0,0 +1,7 @@ +package envutil + +type Hash string + +func (h *Hash) String() string { + return string(*h) +} diff --git a/pkg/envutil/envutil.go b/pkg/envutil/envutil.go index b234b192..73d78722 100644 --- a/pkg/envutil/envutil.go +++ b/pkg/envutil/envutil.go @@ -23,8 +23,6 @@ func Merge(a []string, b []string) []string { return r } - println("herererr") - for _, v := range b { pair := strings.SplitN(v, "=", 2) envKeys[pair[0]] = v diff --git a/pkg/envutil/envutil_test.go b/pkg/envutil/envutil_test.go index ce4b4c39..a51930cb 100644 --- a/pkg/envutil/envutil_test.go +++ b/pkg/envutil/envutil_test.go @@ -1,6 +1,7 @@ package envutil import ( + "sort" "testing" "github.com/stretchr/testify/assert" @@ -37,6 +38,9 @@ func TestMergeEnv(t *testing.T) { for _, tc := range tests { t.Log(tc.description) - assert.Equal(t, tc.expectedResult, Merge(tc.first, tc.second)) + sort.Strings(tc.expectedResult) + result := Merge(tc.first, tc.second) + sort.Strings(result) + assert.Equal(t, tc.expectedResult, result) } } diff --git a/pkg/envutil/store.go b/pkg/envutil/store.go new file mode 100644 index 00000000..c935f72f --- /dev/null +++ b/pkg/envutil/store.go @@ -0,0 +1,7 @@ +package envutil + +type Store map[Hash][]string + +func NewStore() Store { + return make(Store) +}