Skip to content

Commit dcbf1be

Browse files
committed
fix unit tests
On-behalf-of: @SAP [email protected]
1 parent 8b7631c commit dcbf1be

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

internal/controller/shard_controller_test.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
. "github.com/onsi/ginkgo/v2"
2323
. "github.com/onsi/gomega"
2424

25+
corev1 "k8s.io/api/core/v1"
2526
"k8s.io/apimachinery/pkg/api/errors"
2627
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2728
"k8s.io/apimachinery/pkg/types"
@@ -43,8 +44,31 @@ var _ = Describe("Shard Controller", func() {
4344
shard := &operatorv1alpha1.Shard{}
4445

4546
BeforeEach(func() {
47+
By("creating the custom resource for the Kind RootShard")
48+
err := k8sClient.Get(ctx, typeNamespacedName, &operatorv1alpha1.RootShard{})
49+
if err != nil && errors.IsNotFound(err) {
50+
resource := &operatorv1alpha1.RootShard{
51+
ObjectMeta: metav1.ObjectMeta{
52+
Name: "my-root-shard",
53+
Namespace: "default",
54+
},
55+
Spec: operatorv1alpha1.RootShardSpec{
56+
External: operatorv1alpha1.ExternalConfig{
57+
Hostname: "example.kcp.io",
58+
Port: 6443,
59+
},
60+
CommonShardSpec: operatorv1alpha1.CommonShardSpec{
61+
Etcd: operatorv1alpha1.EtcdConfig{
62+
Endpoints: []string{"https://localhost:2379"},
63+
},
64+
},
65+
},
66+
}
67+
Expect(k8sClient.Create(ctx, resource)).To(Succeed())
68+
}
69+
4670
By("creating the custom resource for the Kind Shard")
47-
err := k8sClient.Get(ctx, typeNamespacedName, shard)
71+
err = k8sClient.Get(ctx, typeNamespacedName, shard)
4872
if err != nil && errors.IsNotFound(err) {
4973
resource := &operatorv1alpha1.Shard{
5074
ObjectMeta: metav1.ObjectMeta{
@@ -57,6 +81,11 @@ var _ = Describe("Shard Controller", func() {
5781
Endpoints: []string{"https://localhost:2379"},
5882
},
5983
},
84+
RootShard: operatorv1alpha1.RootShardConfig{
85+
Reference: &corev1.LocalObjectReference{
86+
Name: "my-root-shard",
87+
},
88+
},
6089
},
6190
}
6291
Expect(k8sClient.Create(ctx, resource)).To(Succeed())

0 commit comments

Comments
 (0)