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

chore: modify test package name #6472

Merged
merged 1 commit into from
Apr 18, 2023

Conversation

l-qing
Copy link
Contributor

@l-qing l-qing commented Mar 31, 2023

Changes

  • chore: modify test package name
    • Try to ensure that only exported functions are tested. I made this mistake in the previous PR.

Ref: https://github.com/tektoncd/community/blob/main/standards.md#go-packages

All exported functions should have tests
  * If your package is named "foo", prefer putting tests in a "foo_test" package in the same folder to ensure that only exported functions are tested

The shell command to search for test package names without the _test suffix is:

  • find . -name "*_test.go" | xargs grep -E '^package ' | grep -Ev '_test$' | grep -v '^./test' | sort

I did not finish all the changes this time because some packages do use private methods or variables.
I hope that we can follow the community's conventions as closely as possible, and provide a reference for the people who submit pull requests in the future.

Submitter Checklist

As the author of this PR, please check off the items in this checklist:

  • Has Docs included if any changes are user facing
  • Has Tests included if any functionality added or changed
  • Follows the commit message standard
  • Meets the Tekton contributor standards (including
    functionality, content, code)
  • Has a kind label. You can add one by adding a comment on this PR that contains /kind <type>. Valid types are bug, cleanup, design, documentation, feature, flake, misc, question, tep
  • Release notes block below has been updated with any user facing changes (API changes, bug fixes, changes requiring upgrade notices or deprecation warnings)
  • Release notes contains the string "action required" if the change requires additional action from users switching to the new release

Release Notes

NONE

@tekton-robot tekton-robot added the release-note-none Denotes a PR that doesnt merit a release note. label Mar 31, 2023
@tekton-robot tekton-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 31, 2023
@tekton-robot
Copy link
Collaborator

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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

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.

@l-qing
Copy link
Contributor Author

l-qing commented Mar 31, 2023

/kind misc

@tekton-robot tekton-robot added the kind/misc Categorizes issue or PR as a miscellaneuous one. label Mar 31, 2023
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/resolution/v1beta1/resolution_request_conversion.go 66.7% 0.0% -66.7
pkg/reconciler/pipelinerun/resources/resultrefresolution.go 92.9% 89.0% -3.9
pkg/resolution/resolver/framework/configstore.go 26.1% 47.8% 21.7

@l-qing
Copy link
Contributor Author

l-qing commented Mar 31, 2023

/retest

@tekton-robot
Copy link
Collaborator

@l-qing: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

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.

@l-qing l-qing force-pushed the chore/modify-test-package-name branch from b7c5416 to 631991e Compare March 31, 2023 08:45
@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Mar 31, 2023
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/framework/configstore.go 26.1% 47.8% 21.7

@l-qing l-qing force-pushed the chore/modify-test-package-name branch from 631991e to 230e5dd Compare April 1, 2023 00:19
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/framework/configstore.go 26.1% 47.8% 21.7

@l-qing l-qing force-pushed the chore/modify-test-package-name branch from 230e5dd to 3d8892b Compare April 3, 2023 07:25
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/framework/configstore.go 26.1% 47.8% 21.7

@l-qing
Copy link
Contributor Author

l-qing commented Apr 3, 2023

/assign @lbernick

Copy link
Member

@QuanZhang-William QuanZhang-William left a comment

Choose a reason for hiding this comment

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

Thanks @l-qing!

Looks like dot import is generally not recommended but useful golang tests. But anyways, the foo_test package can be used as a reference for people submitting PR in the future for sure👍 .

Related: #5111

@vdemeester
Copy link
Member

Looks like dot import is the suggested method for golang tests. I agree this PR can be used as a reference for people submitting PR in the future .

😅

@vdemeester
Copy link
Member

/ok-to-test

@tekton-robot tekton-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 4, 2023
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/resolution/resolver/framework/configstore.go 26.1% 47.8% 21.7

@vdemeester
Copy link
Member

So the use of dot-import here is to not have to prefix all types with v1 right ? The doc use case is more about circular dependencies, but I see it relatively useful here as well (to not have to rewrite all Pipeline to v1.Pipeline, etc..)

The import . form can be useful in tests that, due to circular dependencies, cannot be made part of the package being tested.

@l-qing l-qing force-pushed the chore/modify-test-package-name branch from 3d8892b to 0ab31a1 Compare April 4, 2023 16:19
@l-qing
Copy link
Contributor Author

l-qing commented Apr 11, 2023

/retest

Copy link
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

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

Just one nit (a typo), otherwise LGTM


import (
"strings"
"testing"

"github.com/tektoncd/pipeline/pkg/apis/pipeline/v1beta1"
prresoruces "github.com/tektoncd/pipeline/pkg/reconciler/pipelinerun/resources"
Copy link
Member

Choose a reason for hiding this comment

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

nit: this looks like a typo ? prresoruces -> prresources

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I have made the adjustments and rebased onto the latest main branch.

@l-qing l-qing force-pushed the chore/modify-test-package-name branch from 8b2a1eb to 2faf8ee Compare April 11, 2023 12:54
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/resolution/v1alpha1/resolution_request_conversion.go 92.9% 53.6% -39.3
pkg/resolution/resolver/framework/configstore.go 26.1% 47.8% 21.7

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/resolution/v1alpha1/resolution_request_conversion.go 92.9% 53.6% -39.3
pkg/resolution/resolver/framework/configstore.go 26.1% 47.8% 21.7

@l-qing
Copy link
Contributor Author

l-qing commented Apr 11, 2023

/cc @vdemeester @jerop

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/resolution/v1alpha1/resolution_request_conversion.go 92.9% 53.6% -39.3
pkg/resolution/resolver/framework/configstore.go 26.1% 47.8% 21.7

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/resolution/v1alpha1/resolution_request_conversion.go 92.9% 53.6% -39.3
pkg/resolution/resolver/framework/configstore.go 26.1% 47.8% 21.7

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 13, 2023
@l-qing l-qing force-pushed the chore/modify-test-package-name branch from 3f4ada2 to 34a67df Compare April 13, 2023 07:10
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 13, 2023
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/resolution/v1alpha1/resolution_request_conversion.go 92.9% 53.6% -39.3
pkg/resolution/resolver/framework/configstore.go 26.1% 47.8% 21.7

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/resolution/v1alpha1/resolution_request_conversion.go 92.9% 53.6% -39.3
pkg/resolution/resolver/framework/configstore.go 26.1% 47.8% 21.7

@l-qing
Copy link
Contributor Author

l-qing commented Apr 13, 2023

/retest

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 15, 2023
@l-qing l-qing force-pushed the chore/modify-test-package-name branch from 34a67df to 7515c37 Compare April 15, 2023 02:43
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Apr 15, 2023
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/resolution/v1alpha1/resolution_request_conversion.go 92.9% 53.6% -39.3
pkg/resolution/resolver/framework/configstore.go 26.1% 47.8% 21.7

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/resolution/v1alpha1/resolution_request_conversion.go 92.9% 53.6% -39.3
pkg/resolution/resolver/framework/configstore.go 26.1% 47.8% 21.7

Try to ensure that only exported functions are tested.

Ref: https://github.com/tektoncd/community/blob/main/standards.md#go-packages

```
All exported functions should have tests
  * If your package is named "foo", prefer putting tests in a "foo_test" package in the same folder to ensure that only exported functions are tested
```

The shell command to search for test package names without the `_test` suffix is:
* `find . -name "*_test.go" | xargs grep -E '^package ' | grep -Ev '_test$' | grep -v '^./test' | sort`
@l-qing l-qing force-pushed the chore/modify-test-package-name branch from 7515c37 to 3b0f7bd Compare April 17, 2023 13:19
@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage-df to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/resolution/v1alpha1/resolution_request_conversion.go 92.9% 53.6% -39.3
pkg/resolution/resolver/framework/configstore.go 26.1% 47.8% 21.7

@tekton-robot
Copy link
Collaborator

The following is the coverage report on the affected files.
Say /test pull-tekton-pipeline-go-coverage to re-run this coverage report

File Old Coverage New Coverage Delta
pkg/apis/resolution/v1alpha1/resolution_request_conversion.go 92.9% 53.6% -39.3
pkg/resolution/resolver/framework/configstore.go 26.1% 47.8% 21.7

@lbernick
Copy link
Member

looks like Jerop and Vincent's feedback has been addressed.
/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Apr 18, 2023
@tekton-robot tekton-robot merged commit 9b30f08 into tektoncd:main Apr 18, 2023
@l-qing
Copy link
Contributor Author

l-qing commented Apr 18, 2023

looks like Jerop and Vincent's feedback has been addressed.

Thank you for your comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. kind/misc Categorizes issue or PR as a miscellaneuous one. lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note-none Denotes a PR that doesnt merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants