test(cli): UpperCamelCase - add input type casing tests for all input types in CLI#2071
Conversation
📝 WalkthroughWalkthroughA new test file validates type casing handling during component version CLI operations. The test exercises Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~30 minutes Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (2)
cli/cmd/type_casing_test.go (2)
256-259: Consider enabling parallel test execution.Each subtest is independent with its own temp directory, making them safe to run in parallel. This could speed up the test suite.
♻️ Proposed change to enable parallel execution
for _, tc := range tests { + tc := tc // capture range variable for parallel execution t.Run(tc.name, func(t *testing.T) { + t.Parallel() r := require.New(t) tmp := t.TempDir()🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cli/cmd/type_casing_test.go` around lines 256 - 259, The subtests in the for loop over tests (inside t.Run in type_casing_test.go) are independent and should be run in parallel to speed up the suite; modify the subtest closure used in t.Run to call t.Parallel() as the first statement (before creating the temp dir and other setup in the closure that currently contains tmp := t.TempDir()), so each subtest executes concurrently without shared state.
304-314: Log verification approach is functional but somewhat fragile.Using
fmt.Sprint(entry)to stringify log entries works but depends on the log entry'sString()or default formatting. If the log structure changes, this could silently break. Consider checking a specific field if the log entry type exposes one, or document this coupling.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@cli/cmd/type_casing_test.go` around lines 304 - 314, The test currently stringifies each log entry with fmt.Sprint(entry) which is fragile; update the verification to inspect a concrete log field (e.g., use the log entry's Message/Msg/Text field) returned by transferLogs.List() instead of fmt.Sprint so the assertion reads something like checking entry.Message contains "transfer completed successfully"; locate the loop iterating over transferEntries (variables transferEntries, entry) and replace the fmt.Sprint usage with the entry's explicit message field or, if the log type has no message field, add a short comment documenting the coupling and assert on a stable field (timestamp/level) or add a helper that extracts the textual message from the entry type.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@cli/cmd/type_casing_test.go`:
- Around line 256-259: The subtests in the for loop over tests (inside t.Run in
type_casing_test.go) are independent and should be run in parallel to speed up
the suite; modify the subtest closure used in t.Run to call t.Parallel() as the
first statement (before creating the temp dir and other setup in the closure
that currently contains tmp := t.TempDir()), so each subtest executes
concurrently without shared state.
- Around line 304-314: The test currently stringifies each log entry with
fmt.Sprint(entry) which is fragile; update the verification to inspect a
concrete log field (e.g., use the log entry's Message/Msg/Text field) returned
by transferLogs.List() instead of fmt.Sprint so the assertion reads something
like checking entry.Message contains "transfer completed successfully"; locate
the loop iterating over transferEntries (variables transferEntries, entry) and
replace the fmt.Sprint usage with the entry's explicit message field or, if the
log type has no message field, add a short comment documenting the coupling and
assert on a stable field (timestamp/level) or add a helper that extracts the
textual message from the entry type.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 554e5699-0e7b-4677-b8c9-490b8696a8ca
📒 Files selected for processing (1)
cli/cmd/type_casing_test.go
✅ Deploy Preview for ocm-website ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…ocalBlob so far) (#2057) On-behalf-of: Gerald Morrison (SAP) <gerald.morrison@sap.com> <!-- markdownlint-disable MD041 --> ## Summary Register UpperCamelCase forms as the primary (default) serialization type for all input types, consistent with the existing convention used by access OCIImage/v1, Helm/v1 etc. ## Changes: - Input types: File/v1 (was file/v1), Dir/v1 (was dir/v1), UTF8/v1 (was utf8/v1), Helm/v1 (was helm/v1) **The localBlob/v1 access type IS NOT touched in the PR.**, but already prepared (including updating all tests using the new types) in [this branch](https://github.com/morri-son/open-component-model/tree/align-type-notation-for-acces-and-input). Lowercase forms remain registered as backward-compatible aliases so existing component descriptors and constructors continue to work. Adds named constants (Type, LegacyType) to each spec package following the pattern already established by access type packages. Also adds Type constants for OCIImage, OCIImageLayer, and Helm access types where hardcoded strings were previously used in schema registrations. ## Which issue(s) this PR fixes Usage: Fixes open-component-model/ocm-project#962 ## Dependencies Tests for type casing have been split off to PR #2071 to get the CI test not failing. ## Related - ocm-spec: open-component-model/ocm-spec#141 - ocm v1: open-component-model/ocm#1881 - ocm-website: #2244 ## Verification - [x] I have tested the changes locally by running `ocm` --------- Signed-off-by: Gerald Morrison (SAP) <gerald.morrison@sap.com> Co-authored-by: Gerald Morrison (SAP) <gerald.morrison@sap.com>
…ocalBlob so far) (open-component-model#2057) On-behalf-of: Gerald Morrison (SAP) <gerald.morrison@sap.com> <!-- markdownlint-disable MD041 --> ## Summary Register UpperCamelCase forms as the primary (default) serialization type for all input types, consistent with the existing convention used by access OCIImage/v1, Helm/v1 etc. ## Changes: - Input types: File/v1 (was file/v1), Dir/v1 (was dir/v1), UTF8/v1 (was utf8/v1), Helm/v1 (was helm/v1) **The localBlob/v1 access type IS NOT touched in the PR.**, but already prepared (including updating all tests using the new types) in [this branch](https://github.com/morri-son/open-component-model/tree/align-type-notation-for-acces-and-input). Lowercase forms remain registered as backward-compatible aliases so existing component descriptors and constructors continue to work. Adds named constants (Type, LegacyType) to each spec package following the pattern already established by access type packages. Also adds Type constants for OCIImage, OCIImageLayer, and Helm access types where hardcoded strings were previously used in schema registrations. ## Which issue(s) this PR fixes Usage: Fixes open-component-model/ocm-project#962 ## Dependencies Tests for type casing have been split off to PR open-component-model#2071 to get the CI test not failing. ## Related - ocm-spec: open-component-model/ocm-spec#141 - ocm v1: open-component-model/ocm#1881 - ocm-website: open-component-model#2244 ## Verification - [x] I have tested the changes locally by running `ocm` --------- Signed-off-by: Gerald Morrison (SAP) <gerald.morrison@sap.com> Co-authored-by: Gerald Morrison (SAP) <gerald.morrison@sap.com> 7756429
e242dca to
e72dbd6
Compare
Verifies that both legacy lowercase (file/v1, dir/v1, utf8/v1, helm/v1) and UpperCamelCase (File/v1, Dir/v1, UTF8/v1, Helm/v1) input type names produce valid component versions with correct access types and content. Signed-off-by: Gerald Morrison (SAP) <gerald.morrison@sap.com>
e72dbd6 to
5a372ef
Compare
Summary
As leftover from the
align type notation for access and inputissue (open-component-model/ocm-project#962)type_casing_test.go) that validatesadd cvfor all input types (file, dir, utf8, helm) in both lowercase (file/v1) and UpperCamelCase (File/v1) forms.LocalBlob/v1) and expected content.t.TempDir()to keep the test self-contained.Test plan
go test ./cmd/ -run Test_Add_Input_Type_Casing)