Skip to content

Commit 9310f58

Browse files
committed
fix unordered map in test
1 parent e8b51ba commit 9310f58

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

internal/utils/tfsdk_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package utils_test
33
import (
44
"context"
55
"reflect"
6+
"sort"
67
"testing"
78

89
"github.com/elastic/terraform-provider-elasticstack/internal/utils"
@@ -393,13 +394,23 @@ func TestTransformMapToSlice(t *testing.T) {
393394
{name: "converts struct", input: mapFull, want: naiveFull},
394395
}
395396

397+
sortFn := func(s []naive) func(i, j int) bool {
398+
return func(i, j int) bool {
399+
return s[i].ID < s[j].ID
400+
}
401+
}
402+
396403
for _, tt := range tests {
397404
t.Run(tt.name, func(t *testing.T) {
398405
var diags diag.Diagnostics
399406
got := utils.TransformMapToSlice(tt.input, path.Empty(), diags,
400407
func(item naive, meta utils.MapMeta) naive {
401408
return item
402409
})
410+
411+
sort.Slice(got, sortFn(got))
412+
sort.Slice(tt.want, sortFn(tt.want))
413+
403414
if !reflect.DeepEqual(got, tt.want) {
404415
t.Errorf("TransformMapToSlice() = %v, want %v", got, tt.want)
405416
}

0 commit comments

Comments
 (0)