You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "Xu-Wentao (via GitHub)" <gi...@apache.org> on 2023/04/03 08:59:50 UTC
[GitHub] [shardingsphere-on-cloud] Xu-Wentao commented on a diff in pull request #286: Add ShardingSphereChaos CRD and convert chaos to Chaos Mesh logic in Reconcile function
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: notifications-unsubscribe@shardingsphere.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org