test: add missing unit tests for mapper package#135
Merged
Conversation
Add 15 new test functions to improve coverage: pkg/mapper/types_test.go (new file): - TestNew_LoggingDisabled: verify New() with logging=false - TestNewRolesAuthMap / TestNewUsersAuthMap: constructor field init - TestRolesAuthMap_String / TestUsersAuthMap_String: String() output format - TestSetters_RolesAuthMap / TestSetters_UsersAuthMap: SetUsername, SetGroups, AppendGroups chaining - TestWithRetry_SucceedsFirstAttempt: WithRetry returns on first success - TestWithRetry_ExhaustsRetries: error wraps "waiter timed out" after N tries pkg/mapper/configmaps_test.go: - TestCreateAuthMap_AlreadyExists: second Create call returns an error pkg/mapper/upsert_test.go: - TestMapper_UpsertMultiple_EmptySlices: empty slices are a no-op - TestMapper_UpsertMultiple_NilInputs: nil slices are handled safely pkg/mapper/remove_test.go: - TestMapper_RemoveRole_PartialMatchARNOnly: ARN+wrong username fails - TestMapper_RemoveUser_PartialMatchARNOnly: ARN+wrong username fails Signed-off-by: Todd Ekenstam <todd_ekenstam@intuit.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #135 +/- ##
==========================================
+ Coverage 58.70% 60.06% +1.36%
==========================================
Files 12 12
Lines 586 586
==========================================
+ Hits 344 352 +8
+ Misses 219 215 -4
+ Partials 23 19 -4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds 15 new test functions across the
pkg/mapper/package to improve coverage of previously untested code paths.New file:
pkg/mapper/types_test.goTestNew_LoggingDisabled—New()with logging disabled sets client and doesn't panicTestNewRolesAuthMap/TestNewUsersAuthMap— constructors initialise all fieldsTestRolesAuthMap_String/TestUsersAuthMap_String—String()output contains expected YAML fieldsTestSetters_RolesAuthMap/TestSetters_UsersAuthMap—SetUsername,SetGroups,AppendGroupschainingTestWithRetry_SucceedsFirstAttempt— returns result on first successful callTestWithRetry_ExhaustsRetries— error wraps"waiter timed out"after N retriespkg/mapper/configmaps_test.goTestCreateAuthMap_AlreadyExists— secondCreateAuthMapcall on same client returns an errorpkg/mapper/upsert_test.goTestMapper_UpsertMultiple_EmptySlices— empty slices are a no-op (configmap unchanged)TestMapper_UpsertMultiple_NilInputs—nilslices handled safely, no crashpkg/mapper/remove_test.goTestMapper_RemoveRole_PartialMatchARNOnly— ARN exists but with wrong username → returns errorTestMapper_RemoveUser_PartialMatchARNOnly— ARN exists but with wrong username → returns errorTest plan
go test -v ./pkg/mapper/...— all 45 tests pass (was 30)🤖 Generated with Claude Code