-
Notifications
You must be signed in to change notification settings - Fork 243
add unit test for DeletePVC #517
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
Conversation
pkg/occlient/occlient_test.go
Outdated
if (len(fakeClientSet.Kubernetes.Actions()) != 1) && (tt.wantErr != true) { | ||
t.Errorf("expected 1 action in DeletePVC got: %v", fakeClientSet.Kubernetes.Actions()) | ||
} | ||
}) |
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.
Just check if fakeClientSet.Kubernetes.Actions()[0].(ktesting.DeleteAction).GetName()
returns name
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.
pkg/occlient/occlient_test.go
Outdated
tests := []struct { | ||
name string | ||
pvcname string | ||
wantErr bool |
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.
One more use for failure as well
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.
Hi @surajnarwade ,
here in this test case, It is only validating whether the correct function is called with the correct parameter, So adding a failure case is not possible
Also according to the Unit test philosophy, we don't need to test the functionality of library function call eg: in this case c.kubeClient.CoreV1().PersistentVolumeClaims(c.namespace).Delete(name, nil)
It's out of our scope of testing because we are in an assumption that the library which we are using is tested by them, and we only need to validate the code which we have written.
This is my understanding so far
81f9d1f
to
4d97561
Compare
hi @syamgk, is this still work in progress? |
@kadel its not |
This LGTM! No comments regarding the code |
@syamgk LGTM |
need rebase |
add unit test for DeletePVC
rebase done, removing label |
add unit test for DeletePVC