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

Refactor controller unit test with proper mock #269

Merged
merged 9 commits into from
Apr 8, 2019

Conversation

zacharya
Copy link
Contributor

@zacharya zacharya commented Apr 5, 2019

Is this a bug fix or adding new feature?
Refactor Cloud interface unit tests to use GoMock

What is this PR about? / Why do we need it?

  • Addresses Refactor controller unit test with proper mock #220 .
  • One thing to discuss - moving cloud.FakeCloudProvider to sanity.fakeCloudProvider required exporting cloud.metadata due to the dependency. I don't see any issues with this, but I figured I'd bring it up in case some of the maintainers see problems.

What testing is done?
Both make test and make test-sanity are running fine.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 5, 2019
@k8s-ci-robot k8s-ci-robot requested review from d-nishi and ddebroy April 5, 2019 03:55
@k8s-ci-robot
Copy link
Contributor

Hi @zacharya. Thanks for your PR.

I'm waiting for a kubernetes-sigs or 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 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 Apr 5, 2019
@coveralls
Copy link

coveralls commented Apr 5, 2019

Pull Request Test Coverage Report for Build 593

  • 22 of 26 (84.62%) changed or added relevant lines in 3 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage increased (+5.3%) to 70.394%

Changes Missing Coverage Covered Lines Changed/Added Lines %
pkg/driver/fakes.go 0 1 0.0%
pkg/driver/controller.go 12 15 80.0%
Files with Coverage Reduction New Missed Lines %
pkg/driver/controller.go 1 68.37%
Totals Coverage Status
Change from base Build 575: 5.3%
Covered Lines: 1001
Relevant Lines: 1422

💛 - Coveralls

@leakingtapan
Copy link
Contributor

/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. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 5, 2019
@zacharya
Copy link
Contributor Author

zacharya commented Apr 5, 2019

/retest

@zacharya
Copy link
Contributor Author

zacharya commented Apr 5, 2019

/retest

@zacharya
Copy link
Contributor Author

zacharya commented Apr 5, 2019

/retest

@leakingtapan
Copy link
Contributor

Im okay with making metadata struct public.

Copy link
Contributor

@leakingtapan leakingtapan left a comment

Choose a reason for hiding this comment

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

Thx for send the PR. The testing code looks much cleaner and we have a higher coverage! I just finished half of the PR. will finish the rest.

pkg/driver/controller_test.go Show resolved Hide resolved
pkg/driver/controller_test.go Outdated Show resolved Hide resolved
pkg/driver/controller_test.go Outdated Show resolved Hide resolved
pkg/driver/controller_test.go Outdated Show resolved Hide resolved
pkg/driver/controller_test.go Show resolved Hide resolved
pkg/driver/controller_test.go Show resolved Hide resolved
pkg/driver/controller_test.go Outdated Show resolved Hide resolved
pkg/driver/controller_test.go Outdated Show resolved Hide resolved
pkg/driver/controller_test.go Outdated Show resolved Hide resolved
pkg/driver/controller_test.go Outdated Show resolved Hide resolved
pkg/driver/controller_test.go Outdated Show resolved Hide resolved
pkg/driver/controller_test.go Outdated Show resolved Hide resolved
pkg/driver/controller_test.go Outdated Show resolved Hide resolved
pkg/driver/controller_test.go Outdated Show resolved Hide resolved
pkg/driver/controller_test.go Outdated Show resolved Hide resolved
pkg/driver/controller_test.go Outdated Show resolved Hide resolved
pkg/driver/controller_test.go Outdated Show resolved Hide resolved
pkg/driver/controller_test.go Outdated Show resolved Hide resolved
pkg/driver/controller_test.go Outdated Show resolved Hide resolved
pkg/driver/node_test.go Outdated Show resolved Hide resolved
@zacharya
Copy link
Contributor Author

zacharya commented Apr 8, 2019

Thanks for the review. I'll knock these out first thing tomorrow.

@zacharya
Copy link
Contributor Author

zacharya commented Apr 8, 2019

@leakingtapan I think I've touched on all of your suggestions. I went through each test case with the goal of making each more readable (rather than bring the dynamic error handling logic over from the previous state). Let me know if you see anything that still needs fixing.

@leakingtapan
Copy link
Contributor

/retest

1 similar comment
@zacharya
Copy link
Contributor Author

zacharya commented Apr 8, 2019

/retest

@leakingtapan
Copy link
Contributor

The code a lot readable and more test covered now Thank @zacharya

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 8, 2019
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: leakingtapan, zacharya

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 Apr 8, 2019
@k8s-ci-robot k8s-ci-robot merged commit c67ab06 into kubernetes-sigs:master Apr 8, 2019
@bertinatto
Copy link
Member

Just a heads up about this PR: we should always squash commits as much as possible.

@leakingtapan
Copy link
Contributor

+1 Forgot to remind @zacharya of doing this.

@zacharya
Copy link
Contributor Author

@bertinatto @leakingtapan Will do next time

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. 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/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants