katzien/go-structure-examples

How do you mock repository interface in a service in hexagonal architecture

Atlasp opened this issue · 0 comments

Since we are returning domain objects (Beer) from a repository our repository is dependent on the domain package.

However, if you try and mock it with gomock it causes a cyclical dependency Because the mock imports from package and then the package improrts the mock so do I:

  1. Return another non-domain object from the repository (hard for slices of Beers for example)
  2. Put the Beer struct in another package
  3. Put the mock inside the package and not in its own folder.