ROSAENG-60112 | test: add tests for OIDC commands#3316
Conversation
|
Skipping CI for Draft Pull Request. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository YAML (base), Central YAML (inherited) Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (6)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughThis pull request adds new Ginkgo/Gomega test files and suite entrypoints across three packages: Sequence Diagram(s)Included above within the hidden review stack artifact per layer. Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 14 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (14 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: olucasfreitas The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/test all |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
cmd/create/oidcprovider/cmd_test.go (1)
25-51: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueMinor duplication in mock response setup.
The OidcConfig/OidcThumbprint responder setup (Lines 30-40) is duplicated verbatim in the failure spec (Lines 72-82). Could be extracted into a small helper to reduce repetition.
Also applies to: 67-94
🤖 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 `@cmd/create/oidcprovider/cmd_test.go` around lines 25 - 51, The OidcConfig and OidcThumbprint responder setup in the CreateOIDCProvider test is duplicated across the success and failure specs, so extract that repeated mock setup into a small helper and reuse it from the CreateOIDCProvider test cases. Keep the helper close to the existing test code and have it encapsulate the shared t.ApiServer.AppendHandlers calls while preserving the existing oidcConfigId and issuerUrl inputs used by CreateOIDCProvider.
🤖 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 `@cmd/create/oidcprovider/cmd_test.go`:
- Around line 25-51: The OidcConfig and OidcThumbprint responder setup in the
CreateOIDCProvider test is duplicated across the success and failure specs, so
extract that repeated mock setup into a small helper and reuse it from the
CreateOIDCProvider test cases. Keep the helper close to the existing test code
and have it encapsulate the shared t.ApiServer.AppendHandlers calls while
preserving the existing oidcConfigId and issuerUrl inputs used by
CreateOIDCProvider.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository YAML (base), Central YAML (inherited)
Review profile: CHILL
Plan: Enterprise
Run ID: 0e4f8200-6bca-4860-b279-b612113584af
📒 Files selected for processing (8)
cmd/create/oidcconfig/cmd_test.gocmd/create/oidcconfig/oidcconfig_suite_test.gocmd/create/oidcprovider/cmd_test.gocmd/create/oidcprovider/oidcprovider_suite_test.gocmd/dlt/oidcconfig/cmd_test.gocmd/dlt/oidcconfig/oidcconfig_suite_test.gocmd/dlt/oidcprovider/cmd_test.gocmd/dlt/oidcprovider/oidcprovider_suite_test.go
Add focused tests for 3 OIDC-related commands, all previously at 0% coverage. Tests target functions that return errors or are pure, without needing to refactor the legacy os.Exit pattern. - cmd/create/oidcconfig: getOidcConfigStrategy factory (5 cases) and ManagedAutoStrategy.executeNoExit (2 cases via OCM mock) - cmd/create/oidcprovider: CreateOIDCProvider exported function (4 cases with OCM + AWS mocks, including FetchOidcThumbprint failure) - cmd/dlt/oidcconfig: getOidcConfigStrategy factory (4 cases) Skip cmd/dlt/oidcprovider (buildCommand is a commandbuilder pass-through already covered by pkg/aws/commandbuilder tests) and cmd/register/oidcconfig (no extracted helpers that return errors).
0862aee to
dcc52c6
Compare
|
@olucasfreitas: The following test failed, say
Full PR test history. Your PR dashboard. DetailsInstructions 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. I understand the commands that are listed here. |
PR Summary
Add focused tests for 4 OIDC-related commands, all previously at 0% coverage. Tests target functions that return errors or are pure, without needing to refactor the legacy os.Exit pattern.
Detailed Description of the Issue
The OIDC commands are required for the STS cluster creation flow and had no automated test coverage. This PR adds tests for the testable internals: strategy factory functions, exported helpers that return errors, and pure command builders.
Related Issues and PRs
Type of Change
Previous Behavior
No automated test coverage for
cmd/create/oidcconfig,cmd/create/oidcprovider,cmd/dlt/oidcconfig, orcmd/dlt/oidcprovider.Behavior After This Change
15 new test cases across 4 commands:
cmd/create/oidcconfiggetOidcConfigStrategyfactory (5 cases),ManagedAutoStrategy.executeNoExit(2 cases)cmd/create/oidcproviderCreateOIDCProviderexported function with OCM + AWS mockscmd/dlt/oidcconfiggetOidcConfigStrategyfactory (4 cases)cmd/dlt/oidcproviderbuildCommandpure functionIntentionally skipped:
cmd/register/oidcconfig(no extracted helpers that return errors).How to Test (Step-by-Step)
Test Steps
go test ./cmd/create/oidcconfig/... ./cmd/create/oidcprovider/... ./cmd/dlt/oidcconfig/... ./cmd/dlt/oidcprovider/... -count=1go vet ./cmd/create/oidcconfig/... ./cmd/create/oidcprovider/... ./cmd/dlt/oidcconfig/... ./cmd/dlt/oidcprovider/...Expected Results
go vetcleanBreaking Changes
Developer Verification Checklist
[JIRA-TICKET] | [TYPE]: <MESSAGE>.make install-hookshas been run in this clone.make testpasses.make lintpasses.Summary by CodeRabbit
go test.