Skip to content
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

Make it easier to write integration tests #38

Open
teohhanhui opened this issue Jul 21, 2023 · 1 comment
Open

Make it easier to write integration tests #38

teohhanhui opened this issue Jul 21, 2023 · 1 comment

Comments

@teohhanhui
Copy link
Contributor

teohhanhui commented Jul 21, 2023

Currently, when we need a DocHandle in a third-party library / app's integration tests, we'd need to spin up an entire thread with Repo::run, while also requiring us to provide our own Storage implementation.

Perhaps test mocks could be provided, similar to tokio_test::io? (Probably not in the same way, as that is trait-based.)

For another reference, check out tonic's mock example.

I'm sure neither of those patterns are directly applicable here, but it's something that could be improved here?

@gterzian
Copy link
Collaborator

gterzian commented Jul 23, 2023

while also requiring us to provide our own Storage implementation

If you are not testing your storage back-end, I suggest using an empty Storage implementation such as SimpleStorage as used in our own test suite.

Currently, when we need a DocHandle in a third-party library / app's integration tests, we'd need to spin up an entire thread with Repo::run, while also requiring us to provide our own Storage implementation.

Do you mean unit-tests? For integration tests that rely on the workings on this library I would recommend doing exactly as in your description of the problem.

If you do mean unit tests, I guess one could work towards adding a mock of the repo, that would not run in a thread but instead follow a per-determined script(return per-determined doc handles and so on). Maybe hide it behind a test flag as opposed to add traits where none are currently needed?

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

No branches or pull requests

2 participants