@@ -16,9 +16,10 @@ package datastore
1616
1717import (
1818 "context"
19- "reflect "
19+ "slices "
2020 "testing"
2121
22+ "github.com/google/go-cmp/cmp"
2223 SchemaClient "github.com/sdcio/data-server/pkg/datastore/clients/schema"
2324 "github.com/sdcio/data-server/pkg/utils"
2425 "github.com/sdcio/data-server/pkg/utils/testhelper"
@@ -237,9 +238,24 @@ func TestDatastore_expandUpdateLeafAsKeys(t *testing.T) {
237238 t .Errorf ("Datastore.expandUpdateLeafAsKeys() error = %v, wantErr %v" , err , tt .wantErr )
238239 return
239240 }
240- if ! reflect .DeepEqual (got , tt .want ) {
241- t .Errorf ("Datastore.expandUpdateLeafAsKeys() = got : %v" , got )
242- t .Errorf ("Datastore.expandUpdateLeafAsKeys() = want: %v" , tt .want )
241+
242+ // convert got to string array
243+ gotStrArr := []string {}
244+ for _ , x := range got {
245+ gotStrArr = append (gotStrArr , x .String ())
246+ }
247+ slices .Sort (gotStrArr )
248+
249+ // convert want to string array
250+ wantStrArr := []string {}
251+ for _ , x := range tt .want {
252+ wantStrArr = append (wantStrArr , x .String ())
253+ }
254+ slices .Sort (wantStrArr )
255+
256+ // compare the string arrays
257+ if diff := cmp .Diff (wantStrArr , gotStrArr ); diff != "" {
258+ t .Fatalf ("mismatch (-want +got)\n %s" , diff )
243259 }
244260 })
245261 }
0 commit comments