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

Add global lock for tests using mongodb #238

Closed
wants to merge 3 commits into from
Closed

Add global lock for tests using mongodb #238

wants to merge 3 commits into from

Conversation

pvdrz
Copy link
Contributor

@pvdrz pvdrz commented May 31, 2022

No description provided.

@pvdrz pvdrz marked this pull request as ready for review May 31, 2022 18:41
@DaughterOfMars
Copy link
Collaborator

Since this is for testing, it seems like it would be better to just use lazy_static, as it will be simpler.

@pvdrz
Copy link
Contributor Author

pvdrz commented May 31, 2022

Since this is for testing, it seems like it would be better to just use lazy_static, as it will be simpler.

why simpler?

EDIT: I tend to favor OnceCell because it's API will eventually make part of std: https://doc.rust-lang.org/std/lazy/index.html

@DaughterOfMars
Copy link
Collaborator

Sure, but this is for testing only, and lazy_static is simpler.

That being said, I think the approach isn't what we want here anyway. I don't think we should be locking tests, but rather creating a wrapper for the database that will drop the database on exit so that tests clean up after themselves.

@pvdrz
Copy link
Contributor Author

pvdrz commented Jun 2, 2022

Sure, but this is for testing only, and lazy_static is simpler.

That being said, I think the approach isn't what we want here anyway. I don't think we should be locking tests, but rather creating a wrapper for the database that will drop the database on exit so that tests clean up after themselves.

what if two tests use the db at the same time? or if one test drops the db and cleans it while the other is using it?

@DaughterOfMars
Copy link
Collaborator

It should not matter if two tests use it at the same time, but if it ever does then we would want a lock for that.

if one test drops the db and cleans it while the other is using it?

This would be an Rc or Arc so that it would only drop when there are no remaining refs.

@DaughterOfMars
Copy link
Collaborator

Superceded by #567

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.

2 participants