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

Add unit test case for pkg/apis/kops/util/versions_test.go #9156

Merged
merged 1 commit into from
May 23, 2020
Merged

Add unit test case for pkg/apis/kops/util/versions_test.go #9156

merged 1 commit into from
May 23, 2020

Conversation

zouy414
Copy link
Contributor

@zouy414 zouy414 commented May 21, 2020

Signed-off-by: ZouYu zouy.fnst@cn.fujitsu.com

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels May 21, 2020
@k8s-ci-robot
Copy link
Contributor

Hi @Hellcatlk. Thanks for your PR.

I'm waiting for a kubernetes 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.

@k8s-ci-robot k8s-ci-robot added area/api size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 21, 2020
@johngmyers
Copy link
Member

I'd prefer the grid to explicitly state whether the test case is expecting success or an error.
/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels May 21, 2020
@zouy414
Copy link
Contributor Author

zouy414 commented May 21, 2020

@johngmyers , done.

Copy link
Member

@johngmyers johngmyers left a comment

Choose a reason for hiding this comment

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

Much better. Still a few minor things to fix.
/assign

}

actual := sv.String()
if actual != expected {
t.Errorf("version mismatch: %q -> %q but expected %q", version, actual, expected)
if actual != c.expected {
Copy link
Member

Choose a reason for hiding this comment

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

This will incorrectly pass if the test case expects an error but the function under test returns success and an empty string.

I usually make expectedError of type string and put the expected error message in it.

Copy link
Member

Choose a reason for hiding this comment

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

Test_TemplateFunctions_CloudControllerConfigArgv shows a pattern where expectedError is an error. That appears to be the current pattern in kops.

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 for your comment, But I can't find where the Test_TemplateFunctions_CloudControllerConfigArgv is.

Copy link
Member

Choose a reason for hiding this comment

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

upup/pkg/fi/cloudup/template_functions_test.go

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thx, done.

},
{
version: "",
expected: "",
Copy link
Member

Choose a reason for hiding this comment

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

You don't need to explicitly list expected: "" for cases that expect an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Signed-off-by: ZouYu <zouy.fnst@cn.fujitsu.com>
@johngmyers
Copy link
Member

Thanks!
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 23, 2020
@rifelpet
Copy link
Member

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Hellcatlk, rifelpet

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 23, 2020
@k8s-ci-robot k8s-ci-robot merged commit a31abc8 into kubernetes:master May 23, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.18 milestone May 23, 2020
@zouy414 zouy414 deleted the UnitTestCase2 branch November 3, 2020 08:28
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. area/api cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", 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. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants