Skip to content

Add storage adapter tests from automerge-repo#59

Open
jmoggr wants to merge 1 commit intoalexjg:mainfrom
jmoggr:storage-adapter-tests
Open

Add storage adapter tests from automerge-repo#59
jmoggr wants to merge 1 commit intoalexjg:mainfrom
jmoggr:storage-adapter-tests

Conversation

@jmoggr
Copy link

@jmoggr jmoggr commented Jan 26, 2026

I needed to implement a storage adapter and was missing the re-useable storage adapter tests that were available in automerge-repo.

Changes:

  • add a public samod::storage::testing module which implements the tests from storage-adapter-tests.ts.
  • add samod/tests/in_memory_storage_tests.rs which runs the samod::storage::testing module tests against the InMemoryStorage storage adapter.
  • Replaces duplicated tests in samod/tests/goi_storage_tests.rs and samod/tests/tokio_storage_tests.rs with the tests from samod::storage::testing.

I've never written re-usable tests in rust before so I'm not sure I've used the "correct" approach. The StorageTestFixture trait made the testing interface explicit and easy to implement while pushing the ugly type shenanigans into the private run_test function. I'm happy to change this if there is a different pattern I should be following.

I could not find the samod equivalent to automerge-repo/src/helpers/tests, so the naming and location of the samod::storage::testing module is just my best guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant