Skip to content

test(): Add comprehensive unit tests for values.go functions#93

Open
Arpit529Srivastava wants to merge 1 commit intokubeslice:masterfrom
Arpit529Srivastava:test/values
Open

test(): Add comprehensive unit tests for values.go functions#93
Arpit529Srivastava wants to merge 1 commit intokubeslice:masterfrom
Arpit529Srivastava:test/values

Conversation

@Arpit529Srivastava
Copy link
Copy Markdown

@Arpit529Srivastava Arpit529Srivastava commented Aug 5, 2025

Description

This PR introduces unit tests for the MergeMaps and GenerateValuesFile functions in pkg/internal/values.go, which handle YAML map merging and Helm values file generation. Both functions have been exported and updated throughout the codebase for improved testability.

Two bugs were fixed: handling of nil maps in MergeMaps, and correcting the merge order in GenerateValuesFile so user values override defaults. The test suite now covers 19 scenarios, including merges, nested maps, empty and nil inputs, error cases, and real-world HelmChart configs. All tests pass and existing functionality is unchanged.

This is under #46 issue

How Has This Been Tested?

  • MergeMaps function with 9 test cases (simple merge, nested merge, nil maps, etc.)
  • GenerateValuesFile function with 7 test cases (basic generation, complex nested values, error handling)
  • Real-world HelmChart configuration testing
  • Error condition testing (invalid file paths, nil inputs)
  • Verified all existing functionality still works with go build and go test

Checklist:

  • The title of the PR states what changed and the related issues number (used for the release note).
  • Does this PR requires documentation updates?
  • I've updated documentation as required by this PR.
  • I have performed a self-review of my own code.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have tested it for all user roles.
  • I have added all the required unit test cases.

Does this PR introduce a breaking change?

No breaking changes. Functions are now exported but maintain the same interface and behavior.

N/A

Signed-off-by: arpit529srivastava <arpitsrivastava529@gmail.com>
@Arpit529Srivastava
Copy link
Copy Markdown
Author

PTAL @narmidm @Rahul-D78 @gourishkb
Thank you

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.

1 participant