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

use status helper functions in pod status unit tests #3141

Conversation

adshmh
Copy link
Contributor

@adshmh adshmh commented Aug 26, 2020

Changes

use status helper functions in pod status unit tests. Addresses #2804 (comment)

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

  • Includes tests (if functionality changed/added)
  • Includes docs (if user facing)
  • Commit messages follow commit message best practices
  • Release notes block has been filled in or deleted (only if no user facing changes)

See the contribution guide for more details.

Double check this list of stuff that's easy to miss:

Reviewer Notes

If API changes are included, additive changes must be approved by at least two OWNERS and backwards incompatible changes must be approved by more than 50% of the OWNERS, and they must first be added in a backwards compatible way.

Release Notes

```release-note
NONE
```

@tekton-robot tekton-robot added release-note-none Denotes a PR that doesnt merit a release note. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 26, 2020
@tekton-robot
Copy link
Collaborator

Hi @adshmh. 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.

@tekton-robot tekton-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Aug 26, 2020
@adshmh
Copy link
Contributor Author

adshmh commented Aug 26, 2020

/cc @pritidesai

@pritidesai
Copy link
Member

/ok-to-test
/kind cleanup

@tekton-robot tekton-robot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. 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 Sep 8, 2020
@adshmh adshmh force-pushed the use-helper-function-in-pkg-pod-status-tests branch 2 times, most recently from fdbd822 to 4406fe6 Compare September 23, 2020 19:25
Comment on lines 1171 to 1174
func statusRunning(t *testing.T) duckv1beta1.Status {
t.Helper()
var trs v1beta1.TaskRunStatus
MarkStatusRunning(&trs, v1beta1.TaskRunReasonRunning.String(), "Not all Steps in the Task have finished executing")
return trs.Status
}

func statusFailure(t *testing.T, message string) duckv1beta1.Status {
t.Helper()
var trs v1beta1.TaskRunStatus
MarkStatusFailure(&trs, message)
return trs.Status
}

func statusSuccess(t *testing.T) duckv1beta1.Status {
t.Helper()
var trs v1beta1.TaskRunStatus
MarkStatusSuccess(&trs)
return trs.Status
}

func statusPending(t *testing.T, reason, message string) duckv1beta1.Status {
t.Helper()
return duckv1beta1.Status{
Conditions: []apis.Condition{{
Type: apis.ConditionSucceeded,
Status: corev1.ConditionUnknown,
Reason: reason,
Message: message,
}},
}
}
Copy link
Member

Choose a reason for hiding this comment

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

All those methods do not need t *testing.T 👼

Copy link
Member

Choose a reason for hiding this comment

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

yes t.Helper() needs access to *t testing.T variable

Copy link
Member

Choose a reason for hiding this comment

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

@pritidesai no need to call t.Helper if the function itself doesn't use *testing.T. t.Helper() is only useful (and needed) if you want the report (t.Log, t.Error, …) done in a function to be reported as the caller of this function. Here, we don't use t *testing.T at all in these functions, so we don't need to call t.Helper(), and so we don't need to pass *testing.T

@tekton-robot tekton-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 25, 2020
@ghost
Copy link

ghost commented Oct 2, 2020

@adshmh just checking in, do you want to carry on with this PR? Looks like there is still some open feedback to address. Cheers!

@adshmh adshmh force-pushed the use-helper-function-in-pkg-pod-status-tests branch from 4406fe6 to 3f05158 Compare October 22, 2020 17:13
@tekton-robot tekton-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 22, 2020
@adshmh
Copy link
Contributor Author

adshmh commented Oct 22, 2020

@adshmh just checking in, do you want to carry on with this PR? Looks like there is still some open feedback to address. Cheers!

Thank you for the reminder. I have updated the PR to address all the reviews.

@adshmh
Copy link
Contributor Author

adshmh commented Oct 22, 2020

/retest

@ghost
Copy link

ghost commented Oct 22, 2020

Thanks for refactoring!

/approve

@tekton-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbwsg

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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 22, 2020
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.

/lgtm

@tekton-robot tekton-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 23, 2020
@tekton-robot tekton-robot merged commit 4c9c6ad into tektoncd:master Oct 23, 2020
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/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. 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/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants