...

Source file src/github.com/chaos-mesh/chaos-mesh/pkg/webhook/config/watcher/config_test.go

Documentation: github.com/chaos-mesh/chaos-mesh/pkg/webhook/config/watcher

     1  // Copyright 2021 Chaos Mesh Authors.
     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  
    16  package watcher
    17  
    18  import (
    19  	. "github.com/onsi/ginkgo"
    20  	. "github.com/onsi/gomega"
    21  )
    22  
    23  var _ = Describe("webhook config watcher", func() {
    24  	Context("Test webhook config", func() {
    25  		It("should return NewConfig", func() {
    26  			config := NewConfig()
    27  			Expect(config.TemplateNamespace).To(Equal(""))
    28  			Expect(config.TargetNamespace).To(Equal(""))
    29  			Expect(config.ConfigLabels).To(Equal(map[string]string{}))
    30  			Expect(config.TemplateLabels).To(Equal(map[string]string{}))
    31  		})
    32  
    33  		It("verift the parameter", func() {
    34  			config := NewConfig()
    35  			Expect(config.Verify()).Should(HaveOccurred())
    36  
    37  			config.TemplateLabels = make(map[string]string)
    38  			config.TemplateLabels["bar"] = "foo"
    39  			Expect(config.Verify()).Should(HaveOccurred())
    40  
    41  			config.ConfigLabels = make(map[string]string)
    42  			config.ConfigLabels["bar"] = "foo"
    43  			Expect(config.Verify()).ShouldNot(HaveOccurred())
    44  		})
    45  
    46  	})
    47  })
    48