-
Notifications
You must be signed in to change notification settings - Fork 184
Conversation
clusterIP: 10.96.0.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The service.yml ClusterIP was invalid ("The Service "test-service" is invalid: spec.clusterIP: Invalid value: "10.0.171.239": provided IP is not in the valid range. The range of valid IPs is 10.96.0.0/16").
This doesn't affect tests or anything. I just happened to try to kubectl apply
the service into a kind cluster and it failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching that!
@@ -1,12 +1,15 @@ | |||
package k8sinternal | |||
package k8sinternal_test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the normal convention that the package test have a different name than the package itself? I've not done this before and I'm wondering if I should have been...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember is something to do with blackbox/whitebox testing 💭. I think when we call this a different name, we would have to import k8sinternal
in order to get access to the rest of the code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly what Brian said! It depends what you want to test.
If you use the same package as the code you're testing (whitebox), you have access to the private methods in the package and can test those.
If you use the special _test
package (normally Go won't let you have multiple package names in the same directory, so appending _test
to the package is a special case), you can test your code as if you were a consumer of the package (blackbox).
In this case we're not testing any private methods so using the "test" package is kind of a cheat to get out of import cycle problems. Alternatively we could move the functions that cause the import cycle into a new package and import that from both k8sinternal
and test
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TYVM for the explainer!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
@@ -1,12 +1,15 @@ | |||
package k8sinternal | |||
package k8sinternal_test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I remember is something to do with blackbox/whitebox testing 💭. I think when we call this a different name, we would have to import k8sinternal
in order to get access to the rest of the code.
clusterIP: 10.96.0.1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for catching that!
Description
Adds a test for #374
Additionally:
ClusterIP
was invalid ("The Service "test-service" is invalid: spec.clusterIP: Invalid value: "10.0.171.239": provided IP is not in the valid range. The range of valid IPs is 10.96.0.0/16")test
package inclient_test.go
caused a circular dependency so updated the package fromk8sinternal
tok8sinternal_test
Type of change
How Has This Been Tested?
Checklist: