Closed longliveenduro closed 7 months ago
Ah sorry, found it...easy..
test("validate password reset link"):
withExpectations():
val authRepo = mock[AuthenticationRepository]
val realmUtil = mock[RealmUtil]
val config = AuthenticationServiceConfig("frontendUrl", verificationNeeded = false)
val authServiceIO = AuthenticationService.configure(authRepo, realmUtil, realmUtil, realmUtil, config)
for
_ <- authServiceIO
two <- 2.pure[IO]
yield expect(two == 2)
Glad to know you found a working solution.
Be aware that the expectation are being verified (by default) when the function passed to withExpectations
returns, which might not do exactly what you want with a lazy data structure like IO
.
If you do not care about verifying expectations, you can disable them with withExpectations(verifyAfterRun = false)
. If you do care about them, I'm not entirely sure it's possible without slightly changing withExpectations
itself.
Thank you very much for your information @fmonniot !
Do you have any proposal how I can verify expectations with IO or do I have to wait for a solution on scala3mock side?
I'm working on a simple cats module. I'm hoping to have it out as a snapshot over the weekend. Note that the next version will have some breaking changes to reduce the number of imports when using the lib.
You can also redefine the withExpectations
function in your own code if you don't want to wait.
I have released a new version with support for cats, that should help with weaver support.
Thank you so much @fmonniot, I will check it out right now.
Have a wonderful day!
@fmonniot 0.6.0 works like a charm with IO. Thank you so much.
Do you know if it works with ZIO as well?
As long as there is a MonadError
instance in scope it should yes. No idea what the state of interop between cats and zio is these days.
How would I integrate "withExpectations" in a test framework that expects a test to return a special type?
E.g. weaver for Cats Effect