wagslane / go-rabbitmq

A wrapper of streadway/amqp that provides reconnection logic and sane defaults
https://blog.boot.dev/golang/connecting-to-rabbitmq-in-golang-easy/
MIT License
768 stars 125 forks source link

interface for connection struct #101

Closed aaqaishtyaq closed 1 year ago

aaqaishtyaq commented 1 year ago

Currently, it is very difficult to write unit tests for the codebase that uses this library. There is no exported interface for the connection struct and it is difficult to mock this.

Please provide guidelines for writing unit tests.

wagslane commented 1 year ago

My first recommendation would be to make sure you're writing unit tests. You might be trying to write integration tests, or unit test at the wrong level (too high) https://blog.boot.dev/clean-code/writing-good-unit-tests-dont-mock-database-connections/

If you're sure you're testing at the right level though, you should be able to create your own interface no?