fix: add global Shutdown function; allow tests to pass on Windows regardless of temp folder state after tests#98
Conversation
This helps tests on Windows work correctly as well as providing a more convenient way to ensure sync to filesystem in local mode
Needed for Windows
This reverts commit 4f6f56e.
There was a problem hiding this comment.
Pull Request Overview
This PR fixes issues with tests failing on Windows by introducing a new global Shutdown function and a Windows‑specific temporary directory helper.
- Introduces a GetTempDir function that applies extra cleanup steps on Windows.
- Replaces mg.ResetSingleton() calls with mg.Shutdown() for proper engine cleanup.
- Updates tests across multiple files to use GetTempDir for file-based URIs.
Reviewed Changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| util_test.go | Added GetTempDir and updated engine cleanup to use Shutdown. |
| update_test.go, query_test.go, insert_test.go, delete_test.go, client_test.go, admin_test.go | Replaced t.TempDir() with GetTempDir(t) for better Windows support. |
| engine.go | Introduced activeEngine tracking and Shutdown functionality; updated error messages. |
| unit_test/api_test.go | Removed TestUserStore, potentially impacting test coverage. |
| CHANGELOG.md | Updated changelog to document the new Shutdown function. |
Comments suppressed due to low confidence (1)
unit_test/api_test.go:1102
- The removal of TestUserStore might reduce coverage of user store functionality. Please verify that this functionality is adequately tested elsewhere or that its removal is intentional.
func TestUserStore(t *testing.T) {
|
Running Code Quality on PRs by uploading data to Trunk will soon be removed. You can still run checks on your PRs using trunk-action - see the migration guide for more information. |
|
@matthewmcneely am I understanding correctly that this avoids the test failure, but running ModusGraph on Windows could still produce unexpected results? |
@ryanfoxtyler |
Description
This tortured PR allows tests to complete on Windows.
Background:
TempDir()function (which deletes the contents of the allocated folder) fails in Windows because the file handles are still activeThis PR adds a Windows-specific TempDir function which tries to delete the folder, but will ultimately fail. But the tests pass.
Note: Windows users will need to manually delete folders created during testing. The folders take the form of
C:\Users\<USER_NAME>\AppData\Local\Temp\modusgraph_test_*Checklist