Thanks for posting this, testing is definitively needed.
At the time this issue was posted, the code was tightly coupled with gRPC and redis. I made some changes which attempts to improve this situation.
A redis client interface is used instead of using the redis client directly
gRPC related code is more decoupled from the rest of the code (compare pkg/kafgo/server.go with pkg/kafgo/kafgo.go
After doing this I created a simple integration test for the pub() function, mostly as a proof of concept. This test implements the new redis client interface to create a redis client mock which is used in the test. For now, the mock only returns success or an error indicating no index was found, which results in a simple test that ensures that no error occurs in a single specific scenario.
I don't have more time to work on this today, but I am planning to work more on the redis client mock in the future to make it able to record requests, and return specific responses. Then it should be possible create much more sophisticated tests.
Thanks for posting this, testing is definitively needed.
At the time this issue was posted, the code was tightly coupled with gRPC and redis. I made some changes which attempts to improve this situation.
pkg/kafgo/server.go
withpkg/kafgo/kafgo.go
After doing this I created a simple integration test for the
pub()
function, mostly as a proof of concept. This test implements the new redis client interface to create a redis client mock which is used in the test. For now, the mock only returns success or an error indicating no index was found, which results in a simple test that ensures that no error occurs in a single specific scenario.I don't have more time to work on this today, but I am planning to work more on the redis client mock in the future to make it able to record requests, and return specific responses. Then it should be possible create much more sophisticated tests.
The changes are ready for review in this PR: https://github.com/rubensseva/kafgo/pull/3