|
| 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 envtest |
| 18 | + |
| 19 | +import ( |
| 20 | + . "github.com/onsi/ginkgo" |
| 21 | + . "github.com/onsi/gomega" |
| 22 | + "k8s.io/apimachinery/pkg/util/sets" |
| 23 | +) |
| 24 | + |
| 25 | +var _ = Describe("Test", func() { |
| 26 | + Describe("readCRDFiles", func() { |
| 27 | + It("should not mix up files from different directories", func() { |
| 28 | + opt := CRDInstallOptions{ |
| 29 | + Paths: []string{ |
| 30 | + "testdata/crds", |
| 31 | + "testdata/crdv1_original", |
| 32 | + }, |
| 33 | + } |
| 34 | + err := readCRDFiles(&opt) |
| 35 | + Expect(err).NotTo(HaveOccurred()) |
| 36 | + |
| 37 | + expectedCRDs := sets.NewString( |
| 38 | + "frigates.ship.example.com", |
| 39 | + "configs.foo.example.com", |
| 40 | + "drivers.crew.example.com", |
| 41 | + ) |
| 42 | + |
| 43 | + foundCRDs := sets.NewString() |
| 44 | + for _, crd := range opt.CRDs { |
| 45 | + foundCRDs.Insert(crd.Name) |
| 46 | + } |
| 47 | + |
| 48 | + Expect(expectedCRDs).To(Equal(foundCRDs)) |
| 49 | + }) |
| 50 | + }) |
| 51 | +}) |
0 commit comments