openebsctl
openebsctl copied to clipboard
Unit testing & refactor for pkg/client
trafficstars
Currently openebsctl project has a K8sClient, which encapsulates all required typed clients for reaching the k8s-apis. Due to the nature of the codebase & huge options, this project sometimes needs a slice of objects and sometimes it needs a the objects mapped to some key. It is the mapping part of the codebase which is repetitive, this can be avoided by casting it to some generic values in such a way that the code outside pkg/client doesn't need modification & no interfaces{} or runtime.Object or metav1.Unstructured are used outside the client package & possible panics() are taken care by strong UTs.
- Methods with a single line do not need unit test coverage
- But methods with mapping logic or some other business logic needs to be tested