-
Notifications
You must be signed in to change notification settings - Fork 73
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 some tests for util/k8sutil/erros.go #32
Conversation
pkg/util/k8sutil/errors_test.go
Outdated
"k8s.io/apimachinery/pkg/util/validation/field" | ||
) | ||
|
||
var conflict = apierrors.NewConflict(schema.GroupResource{"fist", "second"}, "something", os.ErrInvalid) |
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.
Group variable in single var block:
var(
conflict = ...
other = ...
)
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.
Fine
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"k8s.io/apimachinery/pkg/util/validation/field" | ||
) | ||
|
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.
Add tests for masked errors. (assert.X(t, maskAny(...))
)
pkg/util/k8sutil/test/events_test.go
Outdated
@@ -0,0 +1,64 @@ | |||
package k8sutil_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 package name ok?
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.
Where should I state the reason (cyclic import) that led to package creation?
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.
Package name should be test
since the folder is named that.
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.
Add a doc.go
with only a header, package test
followed by a comment describing about the cycle import.
|
||
func TestPodGoneEvent(t *testing.T) { | ||
event := k8sutil.NewPodGoneEvent("name", "role", &apiObjectForTest) | ||
assert.Equal(t, event.Reason, "Pod Of Role Gone") |
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.
role is uppercase in reason but not in message
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.
?
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 use of strings.Title
seems to be a bit inconsistent.
In the following snipped it is used in the middle of the string in one case and in the other case it is not:
62 // NewPodGoneEvent creates an event indicating that a pod is missing
63 func NewPodGoneEvent(podName, role string, apiObject APIObject) *v1.Event {
64 event := newDeploymentEvent(apiObject)
65 event.Type = v1.EventTypeNormal
66 event.Reason = fmt.Sprintf("Pod Of %s Gone", strings.Title(role))
67 event.Message = fmt.Sprintf("Pod %s of member %s is gone", podName, role)
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'm following the etcd-operator on this
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.
All new files need a copyright header.
Copy from one of the existing files.
pkg/util/k8sutil/errors_test.go
Outdated
|
||
func TestIsAlreadyExists(t *testing.T) { | ||
assert.False(t, IsAlreadyExists(conflictError)) | ||
assert.False(t, IsConflict(maskAny(invalidError))) |
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.
IsConflict
-> IsAlreadyExists
pkg/util/k8sutil/errors_test.go
Outdated
|
||
func TestIsNotFound(t *testing.T) { | ||
assert.False(t, IsNotFound(invalidError)) | ||
assert.False(t, IsConflict(maskAny(invalidError))) |
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.
IsConflict
-> IsNotFound
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.
LGTM
first ridiculous commits