Skip to content

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

Merged
merged 1 commit into from
Jun 21, 2018
Merged

Conversation

syamgk
Copy link
Member

@syamgk syamgk commented Jun 7, 2018

add unit test for DeletePVC

@syamgk syamgk added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. Required by Prow. labels Jun 7, 2018
if (len(fakeClientSet.Kubernetes.Actions()) != 1) && (tt.wantErr != true) {
t.Errorf("expected 1 action in DeletePVC got: %v", fakeClientSet.Kubernetes.Actions())
}
})
Copy link
Contributor

@ashetty1 ashetty1 Jun 8, 2018

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

Copy link
Member Author

Choose a reason for hiding this comment

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

yep, it did return the tt.name,

added checks for validating it.

thanks, @ashetty1

@kadel kadel added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Jun 11, 2018
tests := []struct {
name string
pvcname string
wantErr bool
Copy link
Contributor

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

Copy link
Member Author

@syamgk syamgk Jun 12, 2018

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

@syamgk syamgk force-pushed the deletePVC-utest branch 5 times, most recently from 81f9d1f to 4d97561 Compare June 12, 2018 04:58
@syamgk syamgk removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. Required by Prow. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. labels Jun 12, 2018
@syamgk syamgk force-pushed the deletePVC-utest branch from 4d97561 to 0251482 Compare June 12, 2018 10:07
@kadel
Copy link
Member

kadel commented Jun 12, 2018

hi @syamgk, is this still work in progress?

@syamgk syamgk removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. Required by Prow. label Jun 12, 2018
@syamgk
Copy link
Member Author

syamgk commented Jun 12, 2018

@kadel its not
also removed the WIP label

@cdrage
Copy link
Member

cdrage commented Jun 13, 2018

This LGTM! No comments regarding the code

@surajnarwade
Copy link
Contributor

@syamgk LGTM

@kadel kadel added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Jun 19, 2018
@kadel
Copy link
Member

kadel commented Jun 19, 2018

need rebase

add unit test for DeletePVC
@syamgk syamgk force-pushed the deletePVC-utest branch from 0251482 to b260cc8 Compare June 21, 2018 07:41
@syamgk
Copy link
Member Author

syamgk commented Jun 21, 2018

rebase done, removing label

@syamgk syamgk removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. Required by Prow. label Jun 21, 2018
@kadel kadel merged commit 4ab95c2 into redhat-developer:master Jun 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants