18
Views
2
Comments
Solved
[Testing Framework] Would it be possible to mock logical filters in aggregates?
testing-framework
Reactive icon
Forge asset by Leonardo Fernandes
Application Type
Reactive

We have a logical filter in one of our aggregates:

 meaning that we get an error if we try to test this:

We could make it so the logic will take place outside of the aggregate, but is there a way to add mocking to the filter input of the aggregates?


Thank you in advance!

2019-07-08 11-04-35
Leonardo Fernandes
 
MVP
Solution

It looks like the issue is that your logic is relying on a logged-in user.

During the test, by default there is no logged-in user, but you can do a login for a particular test. I recommend you to create a User record, and then invoke LoginTestingUser. After that, your filter will work and will fetch the name of the user that you have created. After the test finishes, the User record will be rolled back.

UserImage.jpg
Jani Verrijp

Ahh that makes sense and it fixed my issue, I should have realised. Thank you for the quick response!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.