-
Notifications
You must be signed in to change notification settings - Fork 476
Removal of browser-storage-memory #11211
Conversation
|
I was not sure about the tests using the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your PR! The removal looks good.
I'll defer to @grigoryk regarding the unit tests. The duplication of the in-memory implementation is a bit unfortunate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The deletion looks good, thanks!
As for the tests, I don't think we need to duplicate these fake implementations.
I think if we were writing these tests from scratch now, we'd just use a mock of the storage, and configure that mock to return the data necessary for the specific tests in question. This will involve updating all of these tests - whenever we add something to the storage, provide the data via the mock instead.
This matches the "test pyramid" kind of approach - we're not testing the storage here, just how we interact with it.
Another option which is also fine and much easier is to update these tests to use PlacesHistoryStorage as a quick way to move forward here. The main downside is that it'll slow down the tests a bit, I think - but probably not by too much.
You'd need to add a testImplementation of browser-storage-sync and testImplementation Dependencies.mozilla_full_megazord_forUnitTests to the gradle files for the affected modules.
Then, you can just just swap out the storage instances in tests with something like val historyStore = PlacesHistoryStorage(testContext).
For an example of this, tests in support-migration use the browser-storage-sync storage layer.
|
Thank you for the detailed explanation @grigoryk. I've done the changes suggested by you, please take a look and let me know if any other changes are required. |
|
There are 11 failed tests in |
|
Yes, they failed locally as well. |
|
Now the tests are getting instrumented correctly but are failing logically due to the usage of PlacesHistoryStorage. I'll have to dig deep to get an understanding of how they are working. Any other option to work with :)? |
Thanks for updating the PR! It seems like assumptions tests were making about behaviour of the old in-memory store don't apply to the real one. I think it's a good thing actually, maybe we'll uncover some real bugs here! I think the way forward is to work through each test failure one-by-one, seeing what's going wrong, fixing the tests and maybe fixing underlying issue if there is one. That's likely quite a bit past the |
|
Okay. I'll try to work with the |
|
@4shutosh I've updated tests in It'd be great if you could do the same for |
|
Sure. On it. |
|
Yeah, that's expected. You switched to use a You'll need to replace bits where we insert stuff into the storage with corresponding mock statements. For example: should be replaced by something like: Before, we'd record a record into the real storage, and it'll just work (since the real storage will also be queried by the toolbar feature). Now, we don't have a real storage to record records into, so we need to fake the "read" part of the storage instead to achieve the same effect for the test. See what ... which tells us that See 3af92af for mocking examples. |
|
Thank you for the beautiful explanation @grigoryk. The tests pass now. I feel I did not try enough to look for that, that was easy enough to be done by myself. Are there any other things that need to be done for this PR? If not please assign me another issue or task as you know better what next should I get going with on this project. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few small things and this should be good to land!
No worries, and thanks for contributing! Looking at the list of issues, we're a bit short right now on those tagged as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✨
|
Thank you for the help 🙌🏻
Yes please do. |


Pull Request checklist
Fixes #11173
After merge