openebsctl icon indicating copy to clipboard operation
openebsctl copied to clipboard

Unit testing & refactor for pkg/client

Open vharsh opened this issue 4 years ago • 0 comments
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

vharsh avatar Jul 26 '21 14:07 vharsh