|
| 1 | +/* |
| 2 | +Copyright 2022 The Kubernetes Authors. |
| 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 v1beta1_test |
| 18 | + |
| 19 | +import ( |
| 20 | + capcv1 "github.com/aws/cluster-api-provider-cloudstack/api/v1beta1" |
| 21 | + "github.com/aws/cluster-api-provider-cloudstack/test/dummies" |
| 22 | + . "github.com/onsi/ginkgo" |
| 23 | + . "github.com/onsi/gomega" |
| 24 | +) |
| 25 | + |
| 26 | +var _ = Describe("CloudStackCluster types", func() { |
| 27 | + |
| 28 | + Context("When retrieving a zone from ZoneStatusMap using GetOne", func() { |
| 29 | + It("Should return nil if ZoneStatusMap is empty", func() { |
| 30 | + zones := capcv1.ZoneStatusMap{} |
| 31 | + Ω(zones.GetOne()).Should(BeNil()) |
| 32 | + }) |
| 33 | + |
| 34 | + It("Should return a zone if ZoneStatusMap is not empty", func() { |
| 35 | + zones := capcv1.ZoneStatusMap{dummies.Zone1.ID: dummies.Zone1} |
| 36 | + Ω(zones.GetOne()).ShouldNot(BeNil()) |
| 37 | + }) |
| 38 | + }) |
| 39 | + |
| 40 | + Context("When retrieving a zone from ZoneStatusMap using GetByName", func() { |
| 41 | + It("Should return nil if ZoneStatusMap is empty", func() { |
| 42 | + zones := capcv1.ZoneStatusMap{} |
| 43 | + Ω(zones.GetByName(dummies.Zone1.Name)).Should(BeNil()) |
| 44 | + }) |
| 45 | + |
| 46 | + It("Should return a zone if ZoneStatusMap has a zone having the name passed into GetByName", func() { |
| 47 | + zones := capcv1.ZoneStatusMap{dummies.Zone1.ID: dummies.Zone1} |
| 48 | + Ω(zones.GetByName(dummies.Zone1.Name)).ShouldNot(BeNil()) |
| 49 | + }) |
| 50 | + |
| 51 | + It("Should return nil if ZoneStatusMap does not have a zone having the name passed into GetByName", func() { |
| 52 | + zones := capcv1.ZoneStatusMap{dummies.Zone2.ID: dummies.Zone2} |
| 53 | + Ω(zones.GetByName(dummies.Zone1.Name)).Should(BeNil()) |
| 54 | + }) |
| 55 | + }) |
| 56 | +}) |
0 commit comments