Add BsonDFromSlice, Add AssertDeepEqual

This commit is contained in:
George Suntres
2026-04-25 10:11:40 -04:00
parent 28dcfb9e4c
commit 13c75f62b1
3 changed files with 66 additions and 2 deletions

20
assert.go Normal file
View File

@@ -0,0 +1,20 @@
package commons
import (
"testing"
"bytes"
"go.mongodb.org/mongo-driver/v2/bson"
)
// AssertDeepEqual compares equality by comparing bytes.
func AssertDeepEqual(t *testing.T, expected, actual any) {
t.Helper()
expJSON, _ := bson.MarshalExtJSON(expected, true, true)
actJSON, _ := bson.MarshalExtJSON(actual, true, true)
if !bytes.Equal(expJSON, actJSON) {
t.Fatalf("expected %s, got %s", expJSON, actJSON)
}
}