test: improve test quality — [Collection] isolation, locale-safe assertions, stronger sanitize check#368
Conversation
…rtions, stronger sanitize check
📝 WalkthroughWalkthroughThree test files receive focused updates: LogServiceSanitizeEdgeCaseTests changes test assertions for user-path sanitization behavior, OperationLockServiceEdgeCaseTests adds test collection organization and refactors event handler patterns, and CleanupCategoryHumanSizeExtendedTests fixes culture-dependent date formatting in assertions. ChangesTest Suite Updates
🎯 2 (Simple) | ⏱️ ~10 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@SysManager/SysManager.Tests/LogServiceSanitizeEdgeCaseTests.cs`:
- Around line 42-47: Replace the loose assertions in
SanitizePath_MultipleUsersInPath_ReplacesAll so the test checks the exact
sanitized output from LogService.SanitizePath instead of just
contains/does-not-contain; assert that result equals the expected string
"C:\Users\[user]\backup\C:\Users\[user]\file.txt" (use the same
verbatim/backslash format as the input) by replacing
Assert.Contains/DoesNotContain calls with a single Assert.Equal(expected,
result) against that exact expected value.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8647737e-b32a-4e5a-9fa3-46c4d9e69a3b
📒 Files selected for processing (3)
SysManager/SysManager.Tests/CleanupCategoryHumanSizeExtendedTests.csSysManager/SysManager.Tests/LogServiceSanitizeEdgeCaseTests.csSysManager/SysManager.Tests/OperationLockServiceEdgeCaseTests.cs
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
- GitHub Check: Build & unit tests
- GitHub Check: Analyze (csharp)
🔇 Additional comments (3)
SysManager/SysManager.Tests/OperationLockServiceEdgeCaseTests.cs (2)
6-6: LGTM!
121-136: LGTM!SysManager/SysManager.Tests/CleanupCategoryHumanSizeExtendedTests.cs (1)
126-128: LGTM!
| public void SanitizePath_MultipleUsersInPath_ReplacesAll() | ||
| { | ||
| var result = LogService.SanitizePath(@"C:\Users\alice\backup\C:\Users\bob\file.txt"); | ||
| Assert.Contains("[user]", result); | ||
| Assert.DoesNotContain("alice", result); | ||
| Assert.DoesNotContain("bob", result); |
There was a problem hiding this comment.
Tighten this test to verify the exact sanitized output.
At Line 45–Line 47, the current checks can still pass if usernames are removed instead of both being replaced with [user]. Since the test is ReplacesAll, assert the full expected string.
✅ Suggested change
var result = LogService.SanitizePath(@"C:\Users\alice\backup\C:\Users\bob\file.txt");
- Assert.Contains("[user]", result);
- Assert.DoesNotContain("alice", result);
- Assert.DoesNotContain("bob", result);
+ Assert.Equal(@"C:\Users\[user]\backup\C:\Users\[user]\file.txt", result);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| public void SanitizePath_MultipleUsersInPath_ReplacesAll() | |
| { | |
| var result = LogService.SanitizePath(@"C:\Users\alice\backup\C:\Users\bob\file.txt"); | |
| Assert.Contains("[user]", result); | |
| Assert.DoesNotContain("alice", result); | |
| Assert.DoesNotContain("bob", result); | |
| public void SanitizePath_MultipleUsersInPath_ReplacesAll() | |
| { | |
| var result = LogService.SanitizePath(@"C:\Users\alice\backup\C:\Users\bob\file.txt"); | |
| Assert.Equal(@"C:\Users\[user]\backup\C:\Users\[user]\file.txt", result); | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@SysManager/SysManager.Tests/LogServiceSanitizeEdgeCaseTests.cs` around lines
42 - 47, Replace the loose assertions in
SanitizePath_MultipleUsersInPath_ReplacesAll so the test checks the exact
sanitized output from LogService.SanitizePath instead of just
contains/does-not-contain; assert that result equals the expected string
"C:\Users\[user]\backup\C:\Users\[user]\file.txt" (use the same
verbatim/backslash format as the input) by replacing
Assert.Contains/DoesNotContain calls with a single Assert.Equal(expected,
result) against that exact expected value.
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…rtions, stronger sanitize check (#368) Co-authored-by: laurentiu021 <laurentiu021@users.noreply.github.com>
Summary
Addresses 3 test quality issues flagged by CodeRabbit.
Changes
OperationLockServiceEdgeCaseTests
CleanupCategoryHumanSizeExtendedTests
LogServiceSanitizeEdgeCaseTests
No release triggered
test: prefix — no version bump.
Summary by CodeRabbit