Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: Use Semantic.DeepEqual to test empty status #1593

Conversation

karlkfi
Copy link
Contributor

@karlkfi karlkfi commented Mar 7, 2025

  • reflect.DeepEqual worked, but Semantic.DeepEqual is preferred for Kubernetes resources.
  • Error with the YAML diff if the status is still set

if len(rg.Status.ResourceStatuses) == 0 {
return fmt.Errorf("found empty status in %s", core.IDOf(obj))
emptyStatus := resourcegroupv1alpha1.ResourceGroupStatus{}
if equality.Semantic.DeepEqual(emptyStatus, rg.Status) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a weak assertion - can the test use testpredicates.ResourceGroupStatusEquals instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, but the output isn't consistent yet until after some other PRs merge.

Copy link
Contributor Author

@karlkfi karlkfi Mar 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preference would just be to keep this weak assertion for now, until all the above fixes have landed, especially because the last two might not get fixed until after we land the inventory client rewrite.

- reflect.DeepEqual worked, but Semantic.DeepEqual is preferred for
  Kubernetes resources.
@karlkfi karlkfi force-pushed the karl-deepequal-status-disabled branch from 841fd21 to 99d010e Compare March 11, 2025 00:39
@google-oss-prow google-oss-prow bot added size/XS and removed size/S labels Mar 11, 2025
Copy link
Contributor

@sdowell sdowell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sdowell

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow bot merged commit 2595d24 into GoogleContainerTools:main Mar 11, 2025
6 checks passed
@karlkfi karlkfi deleted the karl-deepequal-status-disabled branch March 11, 2025 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants