Skip to content

ROSAENG-62146: New action tests making sure that the actions are doing what they are supposed to do and only that - #59

Open
Nikokolas3270 wants to merge 1 commit into
openshift-online:mainfrom
Nikokolas3270:ROSAENG-62146
Open

ROSAENG-62146: New action tests making sure that the actions are doing what they are supposed to do and only that#59
Nikokolas3270 wants to merge 1 commit into
openshift-online:mainfrom
Nikokolas3270:ROSAENG-62146

Conversation

@Nikokolas3270

@Nikokolas3270 Nikokolas3270 commented Aug 11, 2026

Copy link
Copy Markdown

I focused on the actions. Please tell me if this is enough to cover https://redhat.atlassian.net/browse/ROSAENG-62146

Summary by CodeRabbit

  • Tests

    • Expanded coverage for actions, including permissions, resource scope, GET/PATCH/DELETE operations, missing inputs, and namespace or cluster-scoped resources.
    • Added validation for resource updates, returned results, error handling, and preservation of unrelated data.
    • Improved test readability and consistency with reusable fixtures and table-driven scenarios.
  • Maintenance

    • Added a compile-time check for authorization interface compatibility.

@openshift-ci
openshift-ci Bot requested review from bergmannf and gvnnn August 11, 2026 14:11
@openshift-ci

openshift-ci Bot commented Aug 11, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign makdaam for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci Bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 11, 2026
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@Nikokolas3270, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 47 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository: openshift-online/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 55eb16d5-197a-495f-bd2f-0f5bd23892c3

📥 Commits

Reviewing files that changed from the base of the PR and between dfc4131 and 4c40f33.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (1)
  • go.mod

Walkthrough

The change expands table-driven Kubernetes action tests with reusable fixtures and broader operation coverage. It updates Go dependencies required by the tests and adds a compile-time check that authorizer implements Authorizer.

Changes

Actions and authorization

Layer / File(s) Summary
Action test fixtures and operation coverage
go.mod, internal/actions/actions_test.go
The tests add reusable ConfigMap, Secret, and Node fixtures with REST mappings. Table-driven cases cover action names, RBAC rules, GET, PATCH, DELETE, namespaces, scopes, errors, mutations, isolation, and final client state.
Authorizer interface assertion
internal/authorization/authorization.go
A compile-time assertion verifies that authorizer implements Authorizer.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: rolandmkunkel

🚥 Pre-merge checks | ✅ 5 | ❌ 6

❌ Failed checks (6 inconclusive)

Check name Status Explanation Resolution
No-Weak-Crypto ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Container-Privileges ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
No-Sensitive-Data-In-Logs ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
No-Hardcoded-Secrets ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
No-Injection-Vectors ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
Ai-Attribution ❓ Inconclusive Repository clone failed, so this custom check could not run with code access. Retry the review run. If this persists, inspect pre-merge custom-check logs for infrastructure or agent runtime failures.
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the new action tests and their purpose, which matches the pull request objectives and main changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ 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.

@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 (3)
internal/actions/actions_test.go (3)

146-175: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Use actionImplName in the subtest name.

The struct field actionImplName is set for each case but never used. The subtest name uses test.action.Name(), which repeats the action verb already asserted in the test. Using actionImplName makes failures easier to attribute.

♻️ Proposed change
-		t.Run(fmt.Sprintf("When using a %s action, name should be %s", test.action.Name(), test.actionName), func(t *testing.T) {
+		t.Run(fmt.Sprintf("When using a %s, name should be %s", test.actionImplName, test.actionName), func(t *testing.T) {
🤖 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 `@internal/actions/actions_test.go` around lines 146 - 175, Update the subtest
name in TestAction_Name to use the table’s actionImplName field instead of
test.action.Name(), while preserving the existing expected actionName assertion.

20-23: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Register list kinds explicitly to remove the fixture workaround.

NewSimpleDynamicClient derives list kinds from the scheme and the seeded objects. The scheme here is empty, so the tracker only knows a list kind when at least one object of that kind is seeded. The comment at Line 366 documents this workaround. NewSimpleDynamicClientWithCustomListKinds removes the constraint and lets a case start with an empty tracker.

♻️ Proposed change
 func newFakeClient(objects ...runtime.Object) *dynamicfake.FakeDynamicClient {
 	scheme := runtime.NewScheme()
-	return dynamicfake.NewSimpleDynamicClient(scheme, objects...)
+	listKinds := map[schema.GroupVersionResource]string{
+		{Group: "", Version: "v1", Resource: "configmaps"}: "ConfigMapList",
+		{Group: "", Version: "v1", Resource: "secrets"}:    "SecretList",
+		{Group: "", Version: "v1", Resource: "nodes"}:      "NodeList",
+	}
+	return dynamicfake.NewSimpleDynamicClientWithCustomListKinds(scheme, listKinds, objects...)
 }
#!/bin/bash
# Confirm the constructor signature in the pinned client-go version.
ver=$(fd -H -t f '^go\.mod$' --exec rg -N -o 'k8s.io/client-go v[0-9.]+' | head -1 | awk '{print $2}')
echo "client-go $ver"
curl -s "https://raw.githubusercontent.com/kubernetes/client-go/${ver}/dynamic/fake/simple.go" \
  | rg -n 'func NewSimpleDynamicClient(WithCustomListKinds)?\(' -A 6
🤖 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 `@internal/actions/actions_test.go` around lines 20 - 23, Update newFakeClient
to use NewSimpleDynamicClientWithCustomListKinds and register the required
resource-to-list-kind mappings explicitly, preserving the variadic seeded-object
setup. Remove the fixture workaround documented near the affected tests so cases
can begin with an empty tracker.

25-36: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Fix the typo in the helper name.

newClientOject is missing a b. Rename it to newClientObject and update the caller at Line 39.

🤖 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 `@internal/actions/actions_test.go` around lines 25 - 36, Rename the test
helper newClientOject to newClientObject and update its caller accordingly,
preserving the helper’s behavior.
🤖 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 `@internal/actions/actions_test.go`:
- Around line 146-175: Update the subtest name in TestAction_Name to use the
table’s actionImplName field instead of test.action.Name(), while preserving the
existing expected actionName assertion.
- Around line 20-23: Update newFakeClient to use
NewSimpleDynamicClientWithCustomListKinds and register the required
resource-to-list-kind mappings explicitly, preserving the variadic seeded-object
setup. Remove the fixture workaround documented near the affected tests so cases
can begin with an empty tracker.
- Around line 25-36: Rename the test helper newClientOject to newClientObject
and update its caller accordingly, preserving the helper’s behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository: openshift-online/coderabbit/.coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 19d70c58-6240-44d6-bec7-91404efd913a

📥 Commits

Reviewing files that changed from the base of the PR and between 2c7226a and dfc4131.

⛔ Files ignored due to path filters (1)
  • go.sum is excluded by !**/*.sum
📒 Files selected for processing (3)
  • go.mod
  • internal/actions/actions_test.go
  • internal/authorization/authorization.go

…g what they are supposed to do and only that
@openshift-ci openshift-ci Bot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 11, 2026
@openshift-ci

openshift-ci Bot commented Aug 15, 2026

Copy link
Copy Markdown

PR needs rebase.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant