|
| 1 | +// Copyright 2021, Pulumi Corporation. |
| 2 | +// |
| 3 | +// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +// you may not use this file except in compliance with the License. |
| 5 | +// You may obtain a copy of the License at |
| 6 | +// |
| 7 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +// |
| 9 | +// Unless required by applicable law or agreed to in writing, software |
| 10 | +// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +// See the License for the specific language governing permissions and |
| 13 | +// limitations under the License. |
| 14 | + |
| 15 | +package provider |
| 16 | + |
| 17 | +import ( |
| 18 | + "testing" |
| 19 | + |
| 20 | + "github.com/stretchr/testify/assert" |
| 21 | +) |
| 22 | + |
| 23 | +// TestFindAndAdoptCertManagerCRDs tests the dynamic CRD finding and adoption functionality |
| 24 | +func TestFindAndAdoptCertManagerCRDs(t *testing.T) { |
| 25 | + // This is a placeholder for testing CRD import functionality based on the |
| 26 | + // example in the prompt that finds CRDs dynamically via listing and filtering |
| 27 | +} |
| 28 | + |
| 29 | +func TestCertManagerCrdsDefaults(t *testing.T) { |
| 30 | + args := &CertManagerArgs{} |
| 31 | + |
| 32 | + // Set default values |
| 33 | + if args.Crds == nil { |
| 34 | + keepFalse := false |
| 35 | + args.Crds = &CertManagerCrds{ |
| 36 | + Keep: &keepFalse, |
| 37 | + } |
| 38 | + } else if args.Crds.Keep == nil { |
| 39 | + keepFalse := false |
| 40 | + args.Crds.Keep = &keepFalse |
| 41 | + } |
| 42 | + |
| 43 | + // Verify that Crds is initialized |
| 44 | + assert.NotNil(t, args.Crds) |
| 45 | + |
| 46 | + // Verify that Keep defaults to false |
| 47 | + assert.NotNil(t, args.Crds.Keep) |
| 48 | + assert.False(t, *args.Crds.Keep) |
| 49 | +} |
| 50 | + |
| 51 | +func TestCertManagerCrdsWithCustomValues(t *testing.T) { |
| 52 | + // Test with custom Keep value set to true |
| 53 | + keepTrue := true |
| 54 | + args := &CertManagerArgs{ |
| 55 | + Crds: &CertManagerCrds{ |
| 56 | + Keep: &keepTrue, |
| 57 | + }, |
| 58 | + } |
| 59 | + |
| 60 | + // Set default values (should not change our custom setting) |
| 61 | + if args.Crds == nil { |
| 62 | + keepFalse := false |
| 63 | + args.Crds = &CertManagerCrds{ |
| 64 | + Keep: &keepFalse, |
| 65 | + } |
| 66 | + } else if args.Crds.Keep == nil { |
| 67 | + keepFalse := false |
| 68 | + args.Crds.Keep = &keepFalse |
| 69 | + } |
| 70 | + |
| 71 | + // Verify that Crds is initialized |
| 72 | + assert.NotNil(t, args.Crds) |
| 73 | + |
| 74 | + // Verify that Keep value is preserved |
| 75 | + assert.NotNil(t, args.Crds.Keep) |
| 76 | + assert.True(t, *args.Crds.Keep) |
| 77 | +} |
0 commit comments