Skip to content

Add tests for openshift-service-ca whiteout etc#32

Merged
stillalearner merged 2 commits into
migtools:mainfrom
aufi:filter-ca-service-resources
Jun 22, 2026
Merged

Add tests for openshift-service-ca whiteout etc#32
stillalearner merged 2 commits into
migtools:mainfrom
aufi:filter-ca-service-resources

Conversation

@aufi

@aufi aufi commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

There is service CA configmap cleanup already. Reported issues most likely didn't use this OpenShift plugin, that needs to be added upstream manually with $ crane plugin-manager add OpenShiftPlugin.

Adding just a test to cover this case.

Related to #27 and #23

Summary by CodeRabbit

  • Tests
    • Added comprehensive test coverage for ConfigMap resource filtering behavior.

There is service CA configmap cleanup already. Reported issues most
likely didn't use this OpenShift plugin, that needs to be added upstream
manually with `$ crane plugin-manager add OpenShiftPlugin`.

Adding just a test to cover this case.

Related to migtools#27
and migtools#23

Signed-off-by: Marek Aufart <maufart@redhat.com>
@aufi aufi changed the title Add tests for openshift-service-ce whiteout Add tests for openshift-service-ca whiteout Jun 18, 2026
@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

A single table-driven test TestConfigMapFiltering is added to openshift/plugin_test.go. It covers OpenShiftTransformPlugin.Run behavior for ConfigMap resources, asserting response.IsWhiteOut based on ConfigMap name (openshift-service-ca.crt, kube-root-ca.crt, custom) and StripDefaultCABundleFlag extra values (true, false, omitted).

Changes

ConfigMap Filtering Test

Layer / File(s) Summary
Table-driven ConfigMap whiteout test
openshift/plugin_test.go
Adds TestConfigMapFiltering with cases covering default CA bundle ConfigMap names (openshift-service-ca.crt, kube-root-ca.crt) and a custom name, each paired with StripDefaultCABundleFlag set to true, false, or omitted. Builds an unstructured ConfigMap, runs the plugin, and asserts response.IsWhiteOut matches the expected value per case.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

A rabbit hops through test cases with glee,
ConfigMaps filtered — whiteout or free!
kube-root-ca and openshift-service-ca too,
The flag says true, false, or just "I'll skip you."
Each assertion hops in, neat and precise,
Table-driven tests are incredibly nice! 🐇✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title directly and specifically references the main change: adding tests for OpenShift service CA configmap whiteout functionality, which aligns with the PR's objective of testing the cleanup logic.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
openshift/plugin_test.go (1)

176-256: 💤 Low value

Consider adding test coverage for invalid flag values and response fields.

The test could be enhanced with:

  1. A test case for an invalid StripDefaultCABundleFlag value (e.g., "invalid") to verify error handling
  2. Assertions for response.Version (should be string(transform.V1)) and response.Patches (should be empty for ConfigMap whiteout cases)

These additions would provide more complete coverage but are not critical since the current test validates the core filtering behavior.

Example test case for invalid flag value
+		{
+			name:           "invalid strip-default-cabundle value should error",
+			configMapName:  "openshift-service-ca.crt",
+			extras:         map[string]string{StripDefaultCABundleFlag: "invalid"},
+			expectWhiteOut: false,
+			description:    "Invalid boolean value should return error",
+		},

And update the error handling to distinguish between expected errors:

 			response, err := plugin.Run(request)
-			if err != nil {
+			if err != nil && !strings.Contains(tt.name, "should error") {
 				t.Fatalf("unexpected error: %v", err)
 			}
+			if err == nil && strings.Contains(tt.name, "should error") {
+				t.Fatalf("expected error but got none")
+			}
🤖 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 `@openshift/plugin_test.go` around lines 176 - 256, Add test coverage for
invalid flag values and response field validation in the TestConfigMapFiltering
function. First, add a new test case to the tests slice that covers an invalid
value for the StripDefaultCABundleFlag (such as "invalid") to ensure error
handling is working correctly. Second, enhance the assertion logic inside the
test loop to validate not only the IsWhiteOut field but also check that
response.Version equals string(transform.V1) and that response.Patches is empty
for ConfigMap whiteout scenarios. This will provide more comprehensive coverage
of the plugin's response contract.
🤖 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.

Nitpick comments:
In `@openshift/plugin_test.go`:
- Around line 176-256: Add test coverage for invalid flag values and response
field validation in the TestConfigMapFiltering function. First, add a new test
case to the tests slice that covers an invalid value for the
StripDefaultCABundleFlag (such as "invalid") to ensure error handling is working
correctly. Second, enhance the assertion logic inside the test loop to validate
not only the IsWhiteOut field but also check that response.Version equals
string(transform.V1) and that response.Patches is empty for ConfigMap whiteout
scenarios. This will provide more comprehensive coverage of the plugin's
response contract.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3a3aa4f5-9f54-4e69-8f53-b572997fd90e

📥 Commits

Reviewing files that changed from the base of the PR and between 1ae5e2a and 9a35878.

📒 Files selected for processing (1)
  • openshift/plugin_test.go

Signed-off-by: Marek Aufart <maufart@redhat.com>
@aufi aufi changed the title Add tests for openshift-service-ca whiteout Add tests for openshift-service-ca whiteout etc Jun 18, 2026

@stillalearner stillalearner left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@stillalearner stillalearner merged commit 923d827 into migtools:main Jun 22, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants