Add unit tests for PermMapper (toMode parsing, constructors, ownership/mode mapping) - #919
Conversation
…p/mode mapping) PermMapperTest previously covered only entry-name mapping. This adds tests for the rest of PermMapper: toMode(String) octal parsing including null/empty -> -1, both the String- and int-mode constructors and their defaults, and map(...) setting uid/gid/user/group and file-vs-dir modes with edge cases (uid/gid 0 and -1, null user/group preserving existing values, strip, prefix). Additive only - no existing test or production code changed.
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #919 +/- ##
============================================
+ Coverage 71.03% 74.15% +3.11%
- Complexity 96 119 +23
============================================
Files 7 8 +1
Lines 580 619 +39
Branches 75 82 +7
============================================
+ Hits 412 459 +47
+ Misses 121 107 -14
- Partials 47 53 +6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks for the contribution. Is there a particular reason why you added the tests? |
|
Thanks for taking a look. The reason: PIT mutation testing showed the existing PermMapper tests executed the class but only caught 9 of 81 mutations (about 11% mutation score), so most of the |
|
All good. I was just surprised. Test coverage is just not a common contribution. |
PermMapperTestcurrently covers only entry-name mapping. This adds tests for the rest ofPermMapper:toMode(String)octal parsing, includingnull/empty →-1String- andint-mode constructors and their defaultsmap(...)setting uid/gid/user/group and file-vs-dir modes, with edge cases (uid/gid0and-1, null user/group preserving existing values,strip,prefix)All additive — no existing test changed, no production code changed. Raises
PermMapperline coverage from ~78% to 100%. Verified green under Java 8 (mvn test -Dtest=PermMapperTest).How this was produced
This PR was generated with an AI-assisted pipeline built around mutation testing (PIT). The pipeline mutates the target class (flipping conditions and changing boundary/edge cases) and runs the existing tests against each mutant. Where a mutant survives (the existing tests do not catch that edge case), it writes a focused test for that case and reruns PIT to confirm the new test actually kills that specific mutant. So every added test is verified to catch a concrete edge case the suite missed before, rather than being speculative or redundant. The change is additive only (no production code modified), and the module builds green under its CI JDK.