-
Notifications
You must be signed in to change notification settings - Fork 420
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
Refactor sink test #882
Refactor sink test #882
Conversation
The following is the coverage report on the affected files.
|
58580a3
to
639ef65
Compare
The following is the coverage report on the affected files.
|
639ef65
to
a589532
Compare
The following is the coverage report on the affected files.
|
a589532
to
bdd91ea
Compare
The following is the coverage report on the affected files.
|
bdd91ea
to
43be775
Compare
The following is the coverage report on the affected files.
|
/lgtm |
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.
looks good to me 👍
minor question on attribute position change
43be775
to
3c07486
Compare
The following is the coverage report on the affected files.
|
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
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.
Just some comments as I try to get into the project more.
// want is the resulting TaskRun(s) created by the EventListener | ||
want []pipelinev1.TaskRun | ||
}{{ | ||
name: "single trigger embedded within EventListener", |
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.
Are there any conventions on test case naming? I generally like this style of naming but have noticed that it is inconsistent throughout the triggers
project.
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.
no hard and fast rule. Ideally the name would be both descriptive and short but if not possible, I prefer a more descriptive but longer name over a shorter one (though you are right we haven't been very consistent about this).
pkg/sink/sink_test.go
Outdated
// Check right resources were created. | ||
got := toTaskRun(t, dynamicClient.Actions()) | ||
// Sort actions (we do not know what order they executed in) | ||
if diff := cmp.Diff(tc.want, got, cmpopts.SortSlices(func(x, y pipelinev1.TaskRun) bool { |
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.
Could this be split into two lines? Otherwise the comment is not really true as we sort and compare in a single line. It would make the code more readable / easier to follow IMO.
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.
sure!
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.
Updated the comment -- we don't technically sort the taskRuns ourselves, cmp.Diff
has an option to sortSlices, we just pass it a function that it can use to compare the TaskRuns when sorting.
"secretKey": []byte("secret"), | ||
}, | ||
} | ||
// Setup for TestHandleEvent_AuthOverride |
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.
Why are these declared in the middle of the file as compared to either at the top or in inside the test func?
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.
We can't put it inside the TestHandleEvent_AuthOverride since these variables are used in the OverrideAuthentication method that we implement for the fakeAuth
type below. We could put these at the top of the file too but given that these are only used for the test below, we declare them close to where they are being used.
3c07486
to
9f8452a
Compare
The following is the coverage report on the affected files.
|
/lgtm |
@MarcelMue: changing LGTM is restricted to collaborators 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/test-infra repository. |
/lgtm |
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
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: khrm 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 |
9f8452a
to
ac2543f
Compare
The following is the coverage report on the affected files.
|
There were a lost of TestHandle* tests with the same copy pasta making it hard to read/modify e.g. they all copied the same code to create PipelineResource templates, used the same eventBody etc. 1. combine most TestHandle into a table driven test 2. use v1beta1 TaskRuns instead of PipelineResources for all tests 3. add a func for creating test servers with core/webhook interceptors 4. refactor test.HMACHeader to take in testing.TB 5. use switch instead of if/else to reduce verbosity in TestHandle_OverrideAuth 6. use test.RawExtension helper for creating triggertemplates Signed-off-by: Dibyo Mukherjee <[email protected]>
ac2543f
to
02cfee5
Compare
The following is the coverage report on the affected files.
|
/lgtm |
Changes
There are two commits in this PR. It's pretty big but a lot of it is deleting duplicated code. The largest change is to take the many TestHandle* tests that all had the same setup steps and combine them into a single table driven test with multiple test cases.
There were a lost of TestHandle* tests with the same copy pasta making
it hard to read/modify e.g. they all copied the same code to create
PipelineResource templates, used the same eventBody etc.
Submitter Checklist
These are the criteria that every PR should meet, please check them off as you
review them:
See the contribution guide for more details.
Release Notes