Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DB shouldn't be required when using @MockBean for repositories #1032

Open
Nahuel92 opened this issue May 23, 2024 · 2 comments
Open

DB shouldn't be required when using @MockBean for repositories #1032

Nahuel92 opened this issue May 23, 2024 · 2 comments

Comments

@Nahuel92
Copy link

Issue description

Hi there!

This is an improvement request/discussion-opener on something I bumped into recently in other issues:

Please feel free to close it if it's innappropriate.

Now, down to business. I consider that the current @MockBean behavior on repositories is not quite right since, as of now, if a repository is mocked with this annotation, a DB is still required for the interceptor chain to create a TX manager (for more info, please read this comment and the previous issues I linked before).

To me, this defeats the purpose of @MockBean as it forces us to still use a real thing (granted, in the end I achieved my goal using H2, but it feels more of a workaround than a proper solution). If a repository is mocked, why the framework still requires a DB when the idea is to not have one in the first place? I may be wrong on my thought, so I'm open to any feedback/suggestion.

Thanks.

P.S.: And thanks for your effort and dedication, I really like Micronaut.

@graemerocher
Copy link
Contributor

I think we would need to do something in the transaction interceptor. WDYT @dstepanov ?

@dstepanov
Copy link
Contributor

I think we should support replacing the target with the interceptor somehow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants