Skip to content

test(cli): UpperCamelCase - add input type casing tests for all input types in CLI#2071

Merged
jakobmoellerdev merged 3 commits into
open-component-model:mainfrom
morri-son:add-upper-camel-case-test
May 7, 2026
Merged

test(cli): UpperCamelCase - add input type casing tests for all input types in CLI#2071
jakobmoellerdev merged 3 commits into
open-component-model:mainfrom
morri-son:add-upper-camel-case-test

Conversation

@morri-son

@morri-son morri-son commented Mar 25, 2026

Copy link
Copy Markdown
Contributor

Summary

As leftover from the align type notation for access and input issue (open-component-model/ocm-project#962)

  • Adds CLI test (type_casing_test.go) that validates add cv for all input types (file, dir, utf8, helm) in both lowercase (file/v1) and UpperCamelCase (File/v1) forms.
  • Verifies each input type produces a resource with correct access type (LocalBlob/v1) and expected content.
  • Helm chart is created inline in t.TempDir() to keep the test self-contained.

Test plan

  • All 8 test cases pass locally (go test ./cmd/ -run Test_Add_Input_Type_Casing)
  • CI passes on PR

@morri-son morri-son requested a review from a team as a code owner March 25, 2026 21:31
@github-actions github-actions Bot added the area/testing Testing related label Mar 25, 2026
@coderabbitai

coderabbitai Bot commented Mar 25, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

A new test file validates type casing handling during component version CLI operations. The test exercises ocm add cv and ocm transfer component-version commands across resource type variations (file, directory, UTF-8, Helm) with different case formats, ensuring correct type normalization and content preservation.

Changes

Cohort / File(s) Summary
Type Casing Test Suite
cli/cmd/type_casing_test.go
New test file with comprehensive test cases validating resource type casing normalization across ocm add cv and ocm transfer component-version CLI operations. Includes test function Test_Add_And_Transfer_Input_Type_Casing and helper function createMinimalHelmChart for test data generation. Validates access type resolution and resource content integrity across multiple resource type variants.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Suggested labels

size/s

Suggested reviewers

  • Skarlso
  • jakobmoellerdev

Poem

🐰 Type casing dances through the CLI,
From file to File, dir to Dir, oh my!
Each case is tested, none left behind,
Transfer flows smoothly, content aligned,
A fluffy test suite hops on by! 🌰

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description check ✅ Passed The PR description clearly relates to the changeset by explaining the purpose of the new test file, its scope (testing input type casing), and the test plan validation.
Title check ✅ Passed The title clearly and specifically summarizes the main change: adding input type casing tests for all input types in the CLI, which aligns with the changeset that adds a comprehensive test file validating type casing behavior.

✏️ 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.

@github-actions github-actions Bot added the size/m Medium label Mar 25, 2026
@morri-son morri-son marked this pull request as draft March 25, 2026 21:33

@coderabbitai coderabbitai Bot 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.

🧹 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's String() 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

📥 Commits

Reviewing files that changed from the base of the PR and between 6b5d591 and 48fd872.

📒 Files selected for processing (1)
  • cli/cmd/type_casing_test.go

@netlify

netlify Bot commented Apr 17, 2026

Copy link
Copy Markdown

Deploy Preview for ocm-website ready!

Name Link
🔨 Latest commit 14c0b7a
🔍 Latest deploy log https://app.netlify.com/projects/ocm-website/deploys/69fc7c5b71130800081ee8bb
😎 Deploy Preview https://deploy-preview-2071--ocm-website.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions github-actions Bot added size/l Large component/github-actions Changes on GitHub Actions or within `.github/` directory and removed size/m Medium labels Apr 17, 2026
morri-son added a commit that referenced this pull request Apr 21, 2026
…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>
ocmbot2 Bot pushed a commit to morri-son/open-component-model that referenced this pull request Apr 21, 2026
…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
@github-actions github-actions Bot added size/m Medium and removed size/l Large labels Apr 22, 2026
@morri-son morri-son added the kind/chore chore, maintenance, etc. label Apr 23, 2026
@morri-son morri-son changed the title test(cli): add type casing tests for input types chore: add tests for all input types, lower and upper case Apr 23, 2026
@morri-son morri-son force-pushed the add-upper-camel-case-test branch from e242dca to e72dbd6 Compare May 4, 2026 15:59
@morri-son morri-son changed the title chore: add tests for all input types, lower and upper case test(cli): add input type casing tests for all input types May 4, 2026
@morri-son morri-son linked an issue May 4, 2026 that may be closed by this pull request
7 tasks
@morri-son morri-son linked an issue May 4, 2026 that may be closed by this pull request
7 tasks
@morri-son morri-son marked this pull request as ready for review May 4, 2026 16:16
@morri-son morri-son changed the title test(cli): add input type casing tests for all input types test(cli): for UpperCamelCase add input type casing tests for all input types in CLI May 4, 2026
@morri-son morri-son changed the title test(cli): for UpperCamelCase add input type casing tests for all input types in CLI test(cli): UpperCamelCase - add input type casing tests for all input types in CLI May 4, 2026
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>
@morri-son morri-son force-pushed the add-upper-camel-case-test branch from e72dbd6 to 5a372ef Compare May 4, 2026 16:58
@jakobmoellerdev jakobmoellerdev enabled auto-merge (squash) May 7, 2026 11:49
@jakobmoellerdev jakobmoellerdev merged commit 56bde7b into open-component-model:main May 7, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/testing Testing related component/github-actions Changes on GitHub Actions or within `.github/` directory kind/chore chore, maintenance, etc. size/m Medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

align type notation for access and input

4 participants