-
Notifications
You must be signed in to change notification settings - Fork 5.9k
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
*: force forbiding to use mock.NewContext
in production code
#56654
Conversation
Hi @lcwangchao. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with I understand the commands that are listed here. Instructions 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. |
b85b0ce
to
da4dcbc
Compare
da4dcbc
to
7af9fee
Compare
mock.Context
in release codemock.NewContext
in production code
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #56654 +/- ##
=================================================
- Coverage 73.3452% 57.5422% -15.8030%
=================================================
Files 1628 1779 +151
Lines 449555 645030 +195475
=================================================
+ Hits 329727 371165 +41438
- Misses 99598 248838 +149240
- Partials 20230 25027 +4797
Flags with carried forward coverage won't be shown. Click here to find out more.
|
mock.NewContext
in production codemock.NewContext
in production code
// RestrictedSQLExecutorKey is the key to represent MockRestrictedSQLExecutorMockRecorder in ctx. | ||
type RestrictedSQLExecutorKey struct{} | ||
|
||
// String implements the string.Stringer interface. | ||
func (k RestrictedSQLExecutorKey) String() string { | ||
return "__MockRestrictedSQLExecutor" | ||
} | ||
|
||
// WrapAsSCtx wraps the MockRestrictedSQLExecutor into sessionctx.Context. | ||
func WrapAsSCtx(exec *MockRestrictedSQLExecutor) sessionctx.Context { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/retest |
@lcwangchao: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions 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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/retest |
@lcwangchao: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions 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. |
21d352c
to
36653d3
Compare
/retest |
@lcwangchao: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions 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. |
/retest |
@lcwangchao: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions 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. |
/retest |
@lcwangchao: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions 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. |
[LGTM Timeline notifier]Timeline:
|
/retest |
@lcwangchao: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions 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 APPROVED This pull-request has been approved by: CbcWestwolf, hawkingrei, tangenta, YangKeao 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 |
/retest |
@lcwangchao: Cannot trigger testing until a trusted user reviews the PR and leaves an In response to this:
Instructions 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. |
What problem does this PR solve?
Issue Number: close #53388
What changed and how does it work?
Add checks to avoid to use
mock.NewContext
in production code.mock.NewContext
to a standalone file which has a//go:build !codes
header to avoid to build this function in production code. So if some one usesmock.NewContext
in some production code,make server
will fail.mock.NewContextDeprecated
and add a// Deprecated
comment for it. This method should only be used in some legacy code.mock.NewContext
usage in other production codes.Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.