Repository navigation
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ritmun The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Codecov Report
@@ Coverage Diff @@
## master #255 +/- ##
==========================================
- Coverage 41.93% 39.70% -2.24%
==========================================
Files 33 32 -1
Lines 2592 2297 -295
==========================================
- Hits 1087 912 -175
+ Misses 1427 1315 -112
+ Partials 78 70 -8
|
| github.com/openshift/cluster-api-provider-gcp v0.0.0 | ||
| github.com/openshift/machine-api-operator v0.2.1-0.20200226185612-9b0170a1ba07 | ||
| github.com/openshift/operator-custom-metrics v0.4.2 | ||
| github.com/openshift/origin v0.0.0-20160503220234-8f127d736703 |
There was a problem hiding this comment.
Removed this by go mod tidy
|
/retest |
|
/cc @anispate |
| rhapiLbIP := ingressList[0].IP | ||
| // ensure forwarding rule exists in GCP for service | ||
| err := gc.ensureGCPForwardingRuleForExtIP(rhapiLbIP) | ||
| err := gc.ensureGCPForwardingRuleForExtIP(rhapiLbIP, getForwardingRuleList) |
There was a problem hiding this comment.
Can ensureGCPForwardingRuleForExtIp call getForwardingRuleList directly given they're in the same package?
There was a problem hiding this comment.
This follows higher order function mocking. It's one of the ways of mocking a function so that we cover precisely the function we're testing. The higher order function is private and is kept extremely simple to isolate the external dependency. https://medium.com/@tahasevim231/mocking-with-high-order-functions-in-go-b76d5a3103d2
There was a problem hiding this comment.
Looking at this again, I'm not convinced getForwadingRuleList needs to be its own function at this point. Its only ever called once and its not a method of the gcp Client but instead takes it as an argument so I don't see much value in it being a function that's only available in this package as it current stands
There was a problem hiding this comment.
It's for mocking the unit test correctly. This is a common method of unit testing. It's increasing coverage, so it's good for the code overall.
There was a problem hiding this comment.
This changes the ergonomics of the code and makes it fairy complicated going forward but with no functional change, except to make mocking tests simpler. We have other functions with a similar pattern that would also all need to be refactored to this pattern if we want to test them as well.
IMO, we should instead abstract out the GCP API client from the gc Client to an interface with the list of required methods. That way we can pass in a mocked or "real" implementation to the gc Client struct.
# Conflicts: # go.mod
|
@ritmun: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. I understand the commands that are listed here. |
Maintenance sprint PR. Added unit test to cover recently added GCP code.
Jira: https://issues.redhat.com/browse/OSD-10308