File tree Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Expand file tree Collapse file tree 1 file changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package utils_test
3
3
import (
4
4
"context"
5
5
"reflect"
6
+ "sort"
6
7
"testing"
7
8
8
9
"github.com/elastic/terraform-provider-elasticstack/internal/utils"
@@ -393,13 +394,23 @@ func TestTransformMapToSlice(t *testing.T) {
393
394
{name : "converts struct" , input : mapFull , want : naiveFull },
394
395
}
395
396
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
+
396
403
for _ , tt := range tests {
397
404
t .Run (tt .name , func (t * testing.T ) {
398
405
var diags diag.Diagnostics
399
406
got := utils .TransformMapToSlice (tt .input , path .Empty (), diags ,
400
407
func (item naive , meta utils.MapMeta ) naive {
401
408
return item
402
409
})
410
+
411
+ sort .Slice (got , sortFn (got ))
412
+ sort .Slice (tt .want , sortFn (tt .want ))
413
+
403
414
if ! reflect .DeepEqual (got , tt .want ) {
404
415
t .Errorf ("TransformMapToSlice() = %v, want %v" , got , tt .want )
405
416
}
You can’t perform that action at this time.
0 commit comments