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
{{ message }}
This repository has been archived by the owner on Oct 17, 2020. It is now read-only.
What is frustrating you?
When a user updates a short link in production, the update will automatically be reflected to the user short link table within PostgreSQL due to the ON UPDATE CASCADE trigger. Within unit tests however, in particular the updater_test suite, any tests that involve checking the user short link repository will not be reliable and may fail, due to the fact that the fake user link repo will not be updated. (The fake version does not benefit from the implicit SQL trigger)
In PR #938 a quick fix was implemented that updates the fake user short link repo when a short link is updated. However, this needs to be done more cleanly in the future. There are multiple repositories that link to short link repository by alias, and they should all be updated in a clean way.
Your solution
@byliuyang and I discussed utilizing https://github.com/short-d/eventbus as a way to solve this problem. The user short link repo can subscribe to the user short link update event using eventbus and be notified of any updates. Once it's notified of an update, it will be able to make the appropriate change to the user short link table.
Alternatives considered In PR #938 I implemented a new method to the UserShortLink interface for updating the relation. This method is unimplemented for the SQL version because it doesn't need to be, while the method will be implemented for the fake version so that tests relying on this relation can pass.
I believe that this solution is also a viable one since there are no direct dependencies on the repositories themselves (it's using the dependencies that currently exist at the use case level) and thus we can opt to continue with this solution if the eventbus solution doesn't end up being as clear and concise.
edit: discussed with @byliuyang, this isn't the right way to go either. eventbus is currently looking like the best solution to the problem, as multiple repositories can be updated at once without writing lots of boilerplate application logic.
Additional context
This is one of the issues created as part of the refactor of short link business logic. (#938)
The text was updated successfully, but these errors were encountered:
What is frustrating you?
When a user updates a short link in production, the update will automatically be reflected to the user short link table within PostgreSQL due to the
ON UPDATE CASCADE
trigger. Within unit tests however, in particular theupdater_test
suite, any tests that involve checking the user short link repository will not be reliable and may fail, due to the fact that the fake user link repo will not be updated. (The fake version does not benefit from the implicit SQL trigger)In PR #938 a quick fix was implemented that updates the fake user short link repo when a short link is updated. However, this needs to be done more cleanly in the future. There are multiple repositories that link to short link repository by alias, and they should all be updated in a clean way.
Your solution
@byliuyang and I discussed utilizing https://github.com/short-d/eventbus as a way to solve this problem. The user short link repo can subscribe to the user short link update event using
eventbus
and be notified of any updates. Once it's notified of an update, it will be able to make the appropriate change to the user short link table.Alternatives considered
In PR #938 I implemented a new method to theUserShortLink
interface for updating the relation. This method is unimplemented for the SQL version because it doesn't need to be, while the method will be implemented for the fake version so that tests relying on this relation can pass.I believe that this solution is also a viable one since there are no direct dependencies on the repositories themselves (it's using the dependencies that currently exist at the use case level) and thus we can opt to continue with this solution if theeventbus
solution doesn't end up being as clear and concise.edit: discussed with @byliuyang, this isn't the right way to go either.
eventbus
is currently looking like the best solution to the problem, as multiple repositories can be updated at once without writing lots of boilerplate application logic.Additional context
This is one of the issues created as part of the refactor of short link business logic. (#938)
The text was updated successfully, but these errors were encountered: