You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
would it be possible to make it such that the BaseIdRepository class implements some kind of trait which includes all the methods not in BaseIdQueries (e.g. findAll, deleteAll)? I am looking to use a cake pattern to allow easy mocking of the repositories for testing and it would be significantly easier if I could refactor them to be used as follows:
trait UserRepositoryComponent {
def userRepository: UserRepository
trait UserRepository extends BaseIdRepository[User,...]
}
trait PostgresUserRepositoryComponent {
val userRepository = new PostgresUserRepository
class PostgresUserRepository extends BaseIdRepositoryImpl[User,...]
}
trait TestUserRepositoryComponent {
val userRepository = mock[UserRepository]
}
It seems cleaner to mock the trait than having to mock the final class instead.
What do you think? I'm happy to work on a PR for this if you think it acceptable.
Cheers,
Hugh
The text was updated successfully, but these errors were encountered:
I'll try to find some time to make the changes in the next couple of weeks. Do you have any preference on the name other than Impl?
Also related - as it stands the underlying TableQuery is protected in the base repository. I found this slightly awkward when for example doing joins across tables which each had a separate repository. Do you have any objection to making this field public?
Hi,
would it be possible to make it such that the
BaseIdRepository
class implements some kind of trait which includes all the methods not inBaseIdQueries
(e.g.findAll
,deleteAll
)? I am looking to use a cake pattern to allow easy mocking of the repositories for testing and it would be significantly easier if I could refactor them to be used as follows:It seems cleaner to mock the trait than having to mock the final class instead.
What do you think? I'm happy to work on a PR for this if you think it acceptable.
Cheers,
Hugh
The text was updated successfully, but these errors were encountered: