-
Notifications
You must be signed in to change notification settings - Fork 53
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tests suite for storage adapters #307
Tests suite for storage adapters #307
Conversation
I added some tests based on the issues I noticed while working on the LevelDbStoradgeAdapter in the side branch. |
While writing the SQLite storadge adapter. I encountered an issue that forces me to ask a question again. Is this test which I added based on the NodeFSStorageAdapter behavior correct? Is this behavior expected? |
@HerbCaudill in this comment you wrote:
I can say that I did that in this PR. Could I ask you to review it? |
Just a kind reminder: @HerbCaudill could you please review this PR? |
automerge-repo/packages/automerge-repo/src/helpers/tests/storage-adapter-tests.ts Lines 145 to 158 in dec8267
I'm pretty sure this is the behavior I would expect - @pvh @alexjg @alexcc thoughts? |
Hi, @bijela-gora - thanks for working on this, looks good and does what it needs to do. I'd like to organize things a little differently, can you allow me to push commits to this PR branch? |
@HerbCaudill thank you for investing time in review. I ticked the 'Allow edits by maintainers' checkbox. Should work now. |
Hi, @bijela-gora - I've pushed my changes, let me know what you think. I've changed the API to match the existing network acceptance tests: I've also changed the keys, payloads etc. to make the tests as easy to read as possible:
I've also added a large payload test with randomly generated data to make sure that everything works with realistic payload sizes as well. |
…should return all the data that is present and not more
For some reason the test doesn't pass in bunch with others, so I change it to make it work
to clarify difference with runStorageAdapterTests
I also rebased on latest Let me know if this all looks good to you, and I'll merge this PR. |
packages/automerge-repo/src/helpers/tests/storage-adapter-tests.ts
Outdated
Show resolved
Hide resolved
packages/automerge-repo/src/helpers/tests/storage-adapter-tests.ts
Outdated
Show resolved
Hide resolved
packages/automerge-repo-storage-nodefs/test/NodeFSStorageAdapter.test.ts
Outdated
Show resolved
Hide resolved
@HerbCaudill thank you! Let's merge? |
This test suite is based on the @acurrieclark comment:
To get production data, I launched the React to-do app from the example directory. I also launched the Node.js server and recorded calls to each public method of the
NodeFSStorageAdapter
instance. That recordings found its place in the test suite. I made buffers smaller for simplicity.The reason why the storage adapter test suite function has such an interface and is used in this specific way is because I think it should be possible to execute suite hooks. For example, I think it's a good idea to clean up temp files after the execution of each test. The suit hooks are a good place for this, because they will be called even if a test fails. But it seems that for testing the NodeFSStoradgeAdapter, calling the suite hook is not necessary.
In addition to all above I have added comments to explain the decision behind and reasons for a change.