refactor: introduce golden file testing to simplify test expectation updates#6148
refactor: introduce golden file testing to simplify test expectation updates#6148rindrics wants to merge 2 commits into
Conversation
…lity - Use golden file comparisons instead of inline expected strings - Use direct comparison for TestPluginEnvironment (not suited for golden files) - Handle AsYAML() error in TestDropLocalNodes instead of discarding it - Normalize spaces to underscores in golden file paths for subtest compatibility - Remove lazy flag registration from isUpdateGolden (already handled in TestMain) - Remove actual output from golden-file-missing errors to avoid leaking secrets in CI logs
|
This PR has multiple commits, and the default merge method is: merge. 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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: Rindrics The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @rindrics. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
|
@koba1t @sarab97 @varshaprasad96 would you accept this PR to run CI tests? |
|
/ok-to-test |
|
@koba1t @sarab97 @varshaprasad96 |
Summary
This PR introduces golden file testing across test packages (
api/resource,api/resmap, andapi/krusty) to simplify updating test expectations when YAML output order changes. This change prepares for PR #6046, which will modifyResource.AsYAML()behavior and is expected to change the output order of generated YAML resources.Background
PR #6046 changes
Resource.AsYAML()to useRNode.MustString()instead ofsigs.k8s.io/yaml.JSONToYAML. This change will preserve the original YAML field order instead of sorting fields alphabetically, which will affect the output order of generated resources.While both orderings are valid YAML, this change requires updating many test expectations to match the new output order. To make these updates easier and more maintainable, we are introducing golden file testing, which separates test expectations from test code and allows for easy updates using a simple flag.
Benefits
-update-goldenflag instead of manually editing test codeTesting
All tests pass with the new golden file infrastructure:
Related PRs and Issues
Resource.AsYAML()to useRNode.MustString()to preserve original YAML formattingMigration Notes
This PR does not change any test behavior or expected outputs. It only changes how test expectations are stored and compared. After PR #6046 is merged, golden files can be updated using the
-update-goldenflag to reflect the new YAML output order.