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

Database mocking not working #88

Open
theaquamarine opened this issue Aug 26, 2019 · 1 comment
Open

Database mocking not working #88

theaquamarine opened this issue Aug 26, 2019 · 1 comment

Comments

@theaquamarine
Copy link
Collaborator

The Pester setup for mocking Get-ZLocationDatabaseFilePath and Get-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.

@theaquamarine
Copy link
Collaborator Author

The issue is the $collection.EnsureIndex('path') which is run against the database every time ZLocation.Service is imported

dboperation {
$collection.EnsureIndex('path')
}

#93 has a fix of sorts in that 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.

if (-not($dbExists)) {
# Create empty db, collection, and index if it doesn't exist
dboperation {
$collection.EnsureIndex('path')
}

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

1 participant