Make SyncFixture users use seperate directories and clean them up #1311
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
It seemed to me that the
Directory.Delete
calls inInitializeAsync
were trying to delete files being used by other tests (and causing failures for me). So, I've adapted the Fixture to use a different directory per SyncFixture. That means we don't know how to clean up old test projects on start, so I'm cleaning them up at the end.It took me a while to figure out how to close pooled open connections. Largely, because there are 3 different
SqliteConnection
classes to choose from and they all haveClearAllPools()
, but I overlooked the 3rd one and that's the one I actually needed 😆.It also not clear to me how we'd only clear the connections to just a single db if we wanted to delete it in e.g. prod.
For a while I thought that the db file was still in use after the tests, because
CrdtProjectsService.CreateProject()
hasvar db = serviceScope.ServiceProvider.GetRequiredService<LcmCrdtDbContext>();
and doesn't dispose the db afterwards. But disposing it didn't help. And I believe that DbContext will get disposed at the end of the current scope?