pipeline icon indicating copy to clipboard operation
pipeline copied to clipboard

Put all `pkg/apis/pipeline/v1beta1/*_test.go` files to `v1beta1_test` package

Open chuangw6 opened this issue 3 years ago β€’ 4 comments

Feature request

Under pkg/apis/pipeline/v1beta1 folder, there are a number of *_test.go files under v1beta1 package, whereas some are under v1beta1_test package. Problem with this is that in some test files under v1beta1 package, if we want to use some test helper functions that are defined in v1beta1_test package, we cannot import them i.e. getContextBasedOnFeatureFlag, enableAlphaAPIFields.

So it might be great to move those *_test.go files under v1beta1_test package. However, a couple of pain points

  • this will change thousand of lines bc we need to import v1beta1 and prefix all functions/structs defined under it.
  • there are LOTS of unexported functions defined in v1beta1 but used in these *_test.go files i.e. example validateParamResults. If we change *_test.go from package v1beta1 to v1beta1_test, we are not sure if it's appropriate to export those functions OR just remove testings for those unexported functions.

Talked to @lbernick about this today. Loop in @JeromeJu for visibility.

So this issue is created to track the thoughts/comments/suggestions about this.

chuangw6 avatar Jul 08 '22 19:07 chuangw6

The motivation here is based on our code standards for tests, which state that we should aim to only test exported functions. FYI @pritidesai

lbernick avatar Jul 08 '22 19:07 lbernick

Note that the main point on the "code standards" is that exported function are tested, the only, for me, is to take with a grain of salt. In an ideal world we would only test exported method ; which tends to make the code base be composed of smaller packages. But we are not in an ideal world πŸ˜….

Also, if there is, sometimes, cases where we would like to exported a function or a set of function but we are not really prepared to support go package users to use those, there is always the possibility to use the special internal package πŸ‘ΌπŸΌ

vdemeester avatar Jul 11 '22 07:07 vdemeester

/assign

JeromeJu avatar Aug 02 '22 15:08 JeromeJu

The test files in v1 would be moved to v1_test in a separated PR from https://github.com/tektoncd/pipeline/pull/5219.

JeromeJu avatar Aug 02 '22 15:08 JeromeJu

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale with a justification. Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with /close with a justification. If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle stale

Send feedback to tektoncd/plumbing.

tekton-robot avatar Oct 31 '22 16:10 tekton-robot

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten with a justification. Rotten issues close after an additional 30d of inactivity. If this issue is safe to close now please do so with /close with a justification. If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle rotten

Send feedback to tektoncd/plumbing.

tekton-robot avatar Nov 30 '22 16:11 tekton-robot

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen with a justification. Mark the issue as fresh with /remove-lifecycle rotten with a justification. If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/close

Send feedback to tektoncd/plumbing.

tekton-robot avatar Dec 30 '22 16:12 tekton-robot

@tekton-robot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen with a justification. Mark the issue as fresh with /remove-lifecycle rotten with a justification. If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/close

Send feedback to tektoncd/plumbing.

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.

tekton-robot avatar Dec 30 '22 16:12 tekton-robot

verified that this could be closed.

JeromeJu avatar Jun 19 '23 20:06 JeromeJu

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale with a justification. Stale issues rot after an additional 30d of inactivity and eventually close. If this issue is safe to close now please do so with /close with a justification. If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle stale

Send feedback to tektoncd/plumbing.

tekton-robot avatar Sep 17 '23 21:09 tekton-robot

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten with a justification. Rotten issues close after an additional 30d of inactivity. If this issue is safe to close now please do so with /close with a justification. If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle rotten

Send feedback to tektoncd/plumbing.

tekton-robot avatar Oct 17 '23 21:10 tekton-robot