Open thebigbone opened 4 months ago
Completely agree. I have set up the CI for the controller, but since there were no tests on the cyctl, I didn't add the tests there. If you would like to add tests to cyctl, you can change this GH action to run them on each push.
Hey @thebigbone, do you have any updates on this?
Hey @thebigbone, do you have any updates on this?
Hey I have not made much progress because of less spare time. I am planning to atleast cover the half of cli in the next week!
Cool, thanks
@petar-cvit should we use minikube
in the github actions for commands like init
and serve
? Or should I just write simple tests which do not require testing on a cluster?
@thebigbone I think it's good enough to test it with unit tests without setting up the cluster, at least for start. We can add tests that require a cluster later on
Hey @thebigbone, do you have any update on cyctl
unit tests? I'm looking to update our CI for cyctl and add a test step
Hey, I should have asked this before but I am stuck at what tests would be sufficient. Should I just compare the output buffer only or should I create fake clientsets for kubernetes commands? Apologies for the delay.
@thebigbone you can create a mock for clientset? You can create and use an interface in the code and then pass a mock in tests
@thebigbone you can create a mock for clientset? You can create and use an interface in the code and then pass a mock in tests
Mock of the k8s client right? And what about the module commands?
@thebigbone you can take an interface here instead of passing CyclopsV1Alpha1Client
struct directly. Then, you can pass a mock struct in your tests and an actual struct in code when creating Modules and other resources.
Same goes for other actions also. We are using ginkgo and gomega for testing in cyclops-ctrl
, so you can use those as well and check how to use mocks with those
Hey @thebigbone, did you manage to create some tests for the cyctl
? Would love to take a look and try to integrate it with our CI
@petar-cvit interested to add tests for the cyctl command line. Shall I start creating the unit tests ?
@Abiji-2020 sure thing, will assign you
@Abiji-2020 I made a K8s client mock you can use in your tests. Still on a PR, but you can branch out from there and implement tests for cyctl. Here is the PR
cc @thebigbone
@petar-cvit thanks very much I am finding it hard to create a mock. you helped me 🧡
I think we should start adding tests and possibly add it to the CI as well? I can start with the cli and aim for a good coverage score