Skip to content

Commit

Permalink
fix unit tests
Browse files Browse the repository at this point in the history
On-behalf-of: @SAP [email protected]
  • Loading branch information
xrstf committed Jan 21, 2025
1 parent 8b7631c commit dcbf1be
Showing 1 changed file with 30 additions and 1 deletion.
31 changes: 30 additions & 1 deletion internal/controller/shard_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"

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

BeforeEach(func() {
By("creating the custom resource for the Kind RootShard")
err := k8sClient.Get(ctx, typeNamespacedName, &operatorv1alpha1.RootShard{})
if err != nil && errors.IsNotFound(err) {
resource := &operatorv1alpha1.RootShard{
ObjectMeta: metav1.ObjectMeta{
Name: "my-root-shard",
Namespace: "default",
},
Spec: operatorv1alpha1.RootShardSpec{
External: operatorv1alpha1.ExternalConfig{
Hostname: "example.kcp.io",
Port: 6443,
},
CommonShardSpec: operatorv1alpha1.CommonShardSpec{
Etcd: operatorv1alpha1.EtcdConfig{
Endpoints: []string{"https://localhost:2379"},
},
},
},
}
Expect(k8sClient.Create(ctx, resource)).To(Succeed())
}

By("creating the custom resource for the Kind Shard")
err := k8sClient.Get(ctx, typeNamespacedName, shard)
err = k8sClient.Get(ctx, typeNamespacedName, shard)
if err != nil && errors.IsNotFound(err) {
resource := &operatorv1alpha1.Shard{
ObjectMeta: metav1.ObjectMeta{
Expand All @@ -57,6 +81,11 @@ var _ = Describe("Shard Controller", func() {
Endpoints: []string{"https://localhost:2379"},
},
},
RootShard: operatorv1alpha1.RootShardConfig{
Reference: &corev1.LocalObjectReference{
Name: "my-root-shard",
},
},
},
}
Expect(k8sClient.Create(ctx, resource)).To(Succeed())
Expand Down

0 comments on commit dcbf1be

Please sign in to comment.