Open theaquamarine opened 5 years ago
The issue is the $collection.EnsureIndex('path')
which is run against the database every time ZLocation.Service
is imported https://github.com/vors/ZLocation/blob/67638c11eaae0bbfc7b3f7eda476d9751a659442/ZLocation/ZLocation.Service.psm1#L113-L115
EnsureIndex()
will not be run against a database file that already exists, so the only contact between tests and a user's real database should be a Test-Path
. https://github.com/vors/ZLocation/blob/c2dfe2c9ed689378c5cefdcec7f40e95b6dc5784/ZLocation/ZLocation.Service.psm1#L135-L139
The Pester setup for mocking
Get-ZLocationDatabaseFilePath
andGet-ZLocationLegacyBackupFilePath
doesn't work: the mocked functions are never actually called and tests run using my actual database.The easiest way to confirm this is lock the production database and run the tests- if they were using the testing database, this wouldn't be an issue, but instead database operations fail. Other tests such as checking mocks are actually called suggest the same thing.