Skip to content

Commit

Permalink
don't care about order in slice compare test
Browse files Browse the repository at this point in the history
  • Loading branch information
eparker-tulip committed Oct 2, 2024
1 parent 461e50e commit d089692
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion lib/oplog/oplogEntry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,32 @@ func rawBson(t *testing.T, data interface{}) bson.Raw {
return raw
}

func arraysMatch(a, b []string) bool {
if len(a) != len(b) {
return false
}
for _, valA := range a {
found := false
for _, valB := range b {
if valA == valB {
found = true
break
}
}
if !found {
return false
}
}
return true
}

func TestMapKeysRaw(t *testing.T) {
want := []string{"key1", "key2", "key3"}
got, err := mapKeysRaw(rawBson(t, map[string]interface{}{"key1": "one", "key2": "two", "key3": "three"}))
if err != nil {
t.Error("mapKeysRaw() error", err)
}
if !reflect.DeepEqual(got, want) {
if !arraysMatch(got, want) {
t.Errorf("mapKeysRaw() = %v, want %v", got, want)
}
}
Expand Down

0 comments on commit d089692

Please sign in to comment.