|
| 1 | +/* |
| 2 | +
|
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package controllers |
| 18 | + |
| 19 | +import ( |
| 20 | + "context" |
| 21 | + |
| 22 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 23 | + "k8s.io/klog/v2/klogr" |
| 24 | + ctrl "sigs.k8s.io/controller-runtime" |
| 25 | + "sigs.k8s.io/controller-runtime/pkg/client" |
| 26 | + |
| 27 | + "github.com/kubernetes-sigs/cluster-api-provider-ibmcloud/api/v1alpha4" |
| 28 | + |
| 29 | + . "github.com/onsi/ginkgo" |
| 30 | + . "github.com/onsi/gomega" |
| 31 | + |
| 32 | +) |
| 33 | + |
| 34 | +var _ = Describe("IBMPowerVSClusterReconciler", func() { |
| 35 | + |
| 36 | + Context("Reconcile an IBMMPowerVSCluster", func() { |
| 37 | + It("should not error and not requeue the request", func() { |
| 38 | + ctx := context.Background() |
| 39 | + |
| 40 | + reconciler := &IBMPowerVSClusterReconciler{ |
| 41 | + Client: k8sClient, |
| 42 | + Log: klogr.New(), |
| 43 | + } |
| 44 | + |
| 45 | + instance := &v1alpha4.IBMPowerVSCluster{ObjectMeta: metav1.ObjectMeta{Name: "foo", Namespace: "default"}} |
| 46 | + |
| 47 | + // Create the IBMPowerVSCluster object and expect the Reconcile to be created |
| 48 | + Expect(k8sClient.Create(ctx, instance)).To(Succeed()) |
| 49 | + defer func() { |
| 50 | + err := k8sClient.Delete(ctx, instance) |
| 51 | + Expect(err).NotTo(HaveOccurred()) |
| 52 | + }() |
| 53 | + |
| 54 | + result, err := reconciler.Reconcile(ctx, ctrl.Request{ |
| 55 | + NamespacedName: client.ObjectKey{ |
| 56 | + Namespace: instance.Namespace, |
| 57 | + Name: instance.Name, |
| 58 | + }, |
| 59 | + }) |
| 60 | + Expect(err).NotTo(HaveOccurred()) |
| 61 | + Expect(result.RequeueAfter).To(BeZero()) |
| 62 | + Expect(result.Requeue).To(BeFalse()) |
| 63 | + }) |
| 64 | + }) |
| 65 | +}) |
0 commit comments