Xu-Wentao commented on code in PR #286:
URL: 
https://github.com/apache/shardingsphere-on-cloud/pull/286#discussion_r1155678080


##########
shardingsphere-operator/pkg/reconcile/ShardingSphereChaos/ShardingSphereChaos_suite_test.go:
##########


Review Comment:
   you can use `fakeClient` to mock client.Client. below is a simple example.
   ```go
   var fakeClient client.Client
   // your new reconciler or controller
   var reconciler *YourReconciler
   
   // register some CRD or resources for your need.
   scheme := runtime.NewScheme()
   Expect(corev1.AddToScheme(scheme)).To(Succeed())
   Expect(appsv1.AddToScheme(scheme)).To(Succeed())
   fakeClient = fake.NewClientBuilder().WithScheme(scheme).Build()
   reconciler = &controllers.YourController{}
   req := reconcile.Request{
                        NamespacedName: client.ObjectKey{
                                Namespace: "test-namespace",
                                Name:      "test-resource",
                        },
                }
   
   // create some resource if needed by fakeClient.Create()
   // Expect(fakeClient.Create(context.Background(), 
&appsv1.Deployment{})).To(Succeed())
   // ...
   
   res, err := reconciler.Reconcile(context.Background(), req)
   Expect(err).NotTo(HaveOccurred())
   // handle res if needed.
   // ...
   ```
   you can move some common code to ginkgo's `BeforeEach` and `AfterEach`. 
Please help yourself.



##########
shardingsphere-operator/pkg/kubernetes/chaos/chaos_mesh_impl.go:
##########


Review Comment:
   can just named this file to `chaos_mesh`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to