Skip to content

pkg/bindings: Add tests for ToParams and helpers#28931

Open
ROKUMATE wants to merge 1 commit into
podman-container-tools:mainfrom
ROKUMATE:test-pkg-bindings-util
Open

pkg/bindings: Add tests for ToParams and helpers#28931
ROKUMATE wants to merge 1 commit into
podman-container-tools:mainfrom
ROKUMATE:test-pkg-bindings-util

Conversation

@ROKUMATE

Copy link
Copy Markdown
Contributor

Fixes: #28930

What

Add unit tests for pkg/bindings/internal/util: ToParams, Changed,
IsSimpleType, and SimpleTypeToParam. These had no test coverage.

Why

ToParams builds the URL query parameters for every binding call, so its
behavior matters broadly and is easy to regress: only non-nil fields are
emitted, the schema tag renames a param (and - omits it), simple types and
fmt.Stringer become a single value, slices become repeated values, and maps
are serialized to JSON. The tests lock this in.

Details

Table-driven tests in pkg/bindings/internal/util/util_test.go covering:

  • IsSimpleType / SimpleTypeToParam for bool/int/uint/string/Stringer and
    non-simple types
  • Changed for set vs nil fields
  • ToParams: nil/typed-nil input, unset fields skipped, simple fields, slices,
    maps (JSON), schema-tag rename and "-" omission, and the slice-of-non-simple
    error path

No production code changes. go test ./pkg/bindings/internal/util/ passes.

Fixes: podman-container-tools#28930
Signed-off-by: ROKUMATE <rohitkumawat0110@gmail.com>
@TomSweeneyRedHat

Copy link
Copy Markdown
Contributor

LGTM, assuming happy tests

@ROKUMATE

Copy link
Copy Markdown
Contributor Author

acc. to me the failing tests are not related to the pr i made as the pr aims for adding unit-test file (no production code change) and all unit jobs passed which are related to it ...

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.

Test coverage for pkg/bindings/internal/util

2 participants