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

RHOAIENG-15772: tests(odh-nbc): fix unintended shadowing of cfg variable #462

Merged

Conversation

jiridanek
Copy link
Member

RHOAIENG-15772

Description

cfg is first declared here

var (
cfg *rest.Config
cli client.Client
envTest *envtest.Environment
ctx context.Context
cancel context.CancelFunc
testNamespaces = []string{}
)

and then the := operator shadows it, and the cfg we are setting is a different cfg. The top cfg remains nil.

This is a nasty Go gotcha, and we aren't the first to have trouble with it. C.f. https://temporal.io/blog/go-shadowing-bad-choices#the-bug for one.

How Has This Been Tested?

make test

Merge criteria:

  • The commits are squashed in a cohesive manner and have meaningful messages.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

…iable

This is a nasty Go gotcha, and we aren't the first to have trouble with it
https://temporal.io/blog/go-shadowing-bad-choices#the-bug
@jstourac
Copy link
Member

/lgtm

@jiridanek
Copy link
Member Author

/approve

Copy link

openshift-ci bot commented Nov 19, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: jiridanek

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

@openshift-merge-bot openshift-merge-bot bot merged commit 658c81d into opendatahub-io:main Nov 19, 2024
15 checks passed
@jiridanek jiridanek deleted the jd_moonlight_shadow branch November 24, 2024 17:50
@jiridanek
Copy link
Member Author

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