karafka-testing
karafka-testing copied to clipboard
Incompatibility of Deserializer with Testing
re: https://karafka.io/docs/Deserialization/#schema-registry_1
We are deserialising using Avro and Schema Registry. What we found was that the suggested AvroRegistryDeserializer code in the docs wasn't compatible with the Testing recommendations by Avro Turf.
Essentially the web mock stub wasn't able to stub the AvroTurf::Messaging.new client due to the client being intialised in the AVRO constant before the stub. Our workaround was to define a method instead, e.g: def avro @avro ||= AvroTurf::Messaging.new(...) end
This meant the client is initialised after the stub has been called.