actions.rs |
Structs to handle actions that mutate the History DB
Places DB operations are complex and often involve several layers of changes which makes them
hard to test. For example, a function that deletes visits in a date range needs to:
- Calculate which visits to delete
- Delete the visits
- Insert visit tombstones
- Update the frecency for non-orphaned affected pages
- Delete orphaned pages
- Insert page tombstones for deleted synced pages
Test all of this functionality at once leads to ugly tests that are hard to reason about and
hard to change. This is especially true since many steps have multiple branches which
multiplies the complexity.
This module is intended to split up operations to make testing simpler. It defines an enum
whose variants encapsulate particular actions. We can use that enum to split operations into
multiple parts, each which can be tested separately: code that calculates which actions to run
and the code to run each action.
Right now, only a couple function use this system, but hopefully we can use it more in the
future. |
16429 |