Unit testing custom marshal/unmarshal BSON functions

I’d like to unit test my custom BSON marshal/unmarshal code but I can’t seem to find a way to register encoders for my custom structs without using options.DatabaseOptions.Registry and mongo.Client.Database("name", databaseOptions).

Is there a way to test it without a full blown integration test?

Try
bson package - go.mongodb.org/mongo-driver/bson - Go Packages and bson package - go.mongodb.org/mongo-driver/bson - Go Packages

buf, err := bson.MarshalWithRegistry(YourCustomRegistry, bson.M{"custom": custom.String()})