Skip to content

🟢 Add Windows-native test coverage for OS provider#6690

Merged
czunker merged 6 commits intomainfrom
czunker/windows_tests
Mar 4, 2026
Merged

🟢 Add Windows-native test coverage for OS provider#6690
czunker merged 6 commits intomainfrom
czunker/windows_tests

Conversation

@czunker
Copy link
Copy Markdown
Contributor

@czunker czunker commented Feb 26, 2026

Summary

  • Add _windows_test.go files to exercise native Windows code paths (registry API, WMI, IP Helper API, fsutil) that were previously untested
  • Covers unit tests for pure helper functions and integration tests that run against real Windows APIs
  • Complements the Windows CI workflow added in ✨ Add Windows test workflow for PR CI #6687

Test files added

File What it tests
providers/os/registry/registrykey_windows_test.go parseRegistryKeyPath() unit tests + GetNativeRegistryKeyItems/GetNativeRegistryKeyChildren integration tests
providers/os/resources/networkinterface/windows_routes_native_test.go formatDestination, formatGateway, getInterfaceName, parseSockaddrInet unit tests + List() integration test
providers/os/fsutil/find_files_windows_test.go handleFsError() unit tests for all error types
providers/os/detector/windows/build_version_windows_test.go GetWindowsOSBuild() integration test via mock local connection
providers/os/detector/windows/wmi_windows_test.go toString/intToString unit tests + GetWmiInformation() integration test

Test plan

🤖 Generated with Claude Code

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Feb 26, 2026

Test Results

5 226 tests   5 222 ✅  2m 20s ⏱️
  409 suites      4 💤
   31 files        0 ❌

Results for commit d70cf5a.

♻️ This comment has been updated with latest results.

@chris-rock
Copy link
Copy Markdown
Member

/review

@mondoo-code-review
Copy link
Copy Markdown

Unable to complete the code review.

Reason: Failed to clone the repository: code review: git fetch: error: RPC failed; curl 56 Recv failure: Connection reset by peer
error: 7323 bytes of body are still expected
fetch-pack: unexpected disconnect while reading sideband packet
fatal: early EOF
fatal: fetch-pack: invalid index-pack output

You can try /review again or reduce the PR size.

@czunker
Copy link
Copy Markdown
Contributor Author

czunker commented Mar 2, 2026

/review

1 similar comment
@czunker
Copy link
Copy Markdown
Contributor Author

czunker commented Mar 2, 2026

/review

Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds well-structured Windows-native unit and integration tests with no correctness issues.

Add _windows_test.go files to exercise native Windows code paths
(registry API, WMI, IP Helper API, fsutil) that were previously
untested. These tests complement the Windows CI workflow from PR #6687.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@czunker czunker force-pushed the czunker/windows_tests branch from db528c5 to 0c7a472 Compare March 3, 2026 15:56
czunker and others added 3 commits March 3, 2026 17:11
The hardcoded /tmp/test_hash path doesn't exist on Windows. Use
t.TempDir() with filepath.Join for a cross-platform temp path.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
afero MemMapFs Chmod doesn't work on Windows, and Unix file permissions
don't apply there. Guard Chmod and permission-based filtering with
runtime.GOOS checks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move the shared mock type from build_version_windows_test.go into its
own file so the cross-file dependency is self-documenting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@czunker
Copy link
Copy Markdown
Contributor Author

czunker commented Mar 3, 2026

/review

1 similar comment
@czunker
Copy link
Copy Markdown
Contributor Author

czunker commented Mar 3, 2026

/review

@czunker czunker marked this pull request as ready for review March 3, 2026 16:33
Copy link
Copy Markdown

@mondoo-code-review mondoo-code-review bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds solid Windows-native test coverage with no correctness issues; one minor improvement possible for test portability.

czunker and others added 2 commits March 4, 2026 06:41
Replace runtime.GOOS guards with a //go:build !windows file
(find_files_unix_test.go) for chmod/permission tests, keeping
find_files_test.go fully cross-platform.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Add defer f.Close() to prevent Windows file-locking error during
t.TempDir() cleanup.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@czunker
Copy link
Copy Markdown
Contributor Author

czunker commented Mar 4, 2026

/review

@czunker czunker merged commit 64dbc1a into main Mar 4, 2026
37 of 39 checks passed
@czunker czunker deleted the czunker/windows_tests branch March 4, 2026 06:18
@github-actions github-actions bot locked and limited conversation to collaborators Mar 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants