-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
test: add unit tests for pkg/resolution/resource
#6433
Conversation
Hi @l-qing. Thanks for your PR. I'm waiting for a tektoncd member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the 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/test-infra repository. |
/kind bug |
The following is the coverage report on the affected files.
|
/assign lbernick |
73d3809
to
277d879
Compare
The following is the coverage report on the affected files.
|
// ResolverName is the type used for a resolver's name and is mostly | ||
// used to ensure the function signatures that accept it are clear on the | ||
// purpose for the given string. | ||
type ResolverName string |
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.
move from:
pipeline/pkg/resolution/resource/resource.go
Lines 26 to 63 in 40763d8
// ResolverName is the type used for a resolver's name and is mostly | |
// used to ensure the function signatures that accept it are clear on the | |
// purpose for the given string. | |
type ResolverName string | |
// Requester is the interface implemented by a type that knows how to | |
// submit requests for remote resources. | |
type Requester interface { | |
// Submit accepts the name of a resolver to submit a request to | |
// along with the request itself. | |
Submit(context.Context, ResolverName, Request) (ResolvedResource, error) | |
} | |
// Request is implemented by any type that represents a single request | |
// for a remote resource. Implementing this interface gives the underlying | |
// type an opportunity to control properties such as whether the name of | |
// a request has particular properties, whether the request should be made | |
// to a specific namespace, and precisely which parameters should be included. | |
type Request interface { | |
Name() string | |
Namespace() string | |
Params() []pipelinev1beta1.Param | |
} | |
// OwnedRequest is implemented by any type implementing Request that also needs | |
// to express a Kubernetes OwnerRef relationship as part of the request being | |
// made. | |
type OwnedRequest interface { | |
OwnerRef() metav1.OwnerReference | |
} | |
// ResolvedResource is implemented by any type that offers a read-only | |
// view of the data and metadata of a resolved remote resource. | |
type ResolvedResource interface { | |
Data() ([]byte, error) | |
Annotations() map[string]string | |
Source() *pipelinev1beta1.ConfigSource | |
} |
avoid cycle import. 😁
The test package references these interfaces.
Line 12 in 40763d8
resolution "github.com/tektoncd/pipeline/pkg/resolution/resource" |
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.
Although moving the interface to write unit tests is not reasonable, since the methods in the test package are referenced in multiple places, I can only choose the way to make the minimum changes.
And I also need to use existing methods in the test package, I don't want to duplicate them here.
/remove-kind bug |
277d879
to
e84e844
Compare
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.
Thanks so much @l-qing! I love that you were able to find two bugs by adding these tests-- that's great!
pkg/resolution/resource/testdata/submit.resolution_request.created.yaml
Outdated
Show resolved
Hide resolved
The following is the coverage report on the affected files.
|
e84e844
to
0647456
Compare
The following is the coverage report on the affected files.
|
Hi, @lbernick. |
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
/retest |
/assign |
b68da6b
to
6db5768
Compare
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
6db5768
to
d8a29c4
Compare
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
d8a29c4
to
4366720
Compare
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
4366720
to
439aaff
Compare
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
439aaff
to
b2311be
Compare
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
b2311be
to
656c279
Compare
The following is the coverage report on the affected files.
|
The following is the coverage report on the affected files.
|
/retest |
/lgtm |
Thanks! |
fix #6429
I found two minor bugs while writing unit tests 😁:
ownerRefsAreEqual
checking owner reference equality to always return false.GenerateDeterministicName
not consider params when generating unique names.These two bugs currently do not have any substantial impact.
Changes
Submitter Checklist
As the author of this PR, please check off the items in this checklist:
functionality, content, code)
/kind <type>
. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tepRelease Notes