sigs.k8s.io/kubebuilder/v3@v3.14.0/pkg/machinery/funcmap_test.go (about)

     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 machinery
    18  
    19  import (
    20  	. "github.com/onsi/ginkgo/v2"
    21  	. "github.com/onsi/gomega"
    22  )
    23  
    24  var _ = Describe("funcmap functions", func() {
    25  	Context("isEmptyString", func() {
    26  		It("should return true for empty strings", func() {
    27  			Expect(isEmptyString("")).To(BeTrue())
    28  		})
    29  
    30  		DescribeTable("should return false for any other string",
    31  			func(str string) { Expect(isEmptyString(str)).To(BeFalse()) },
    32  			Entry(`for "a"`, "a"),
    33  			Entry(`for "1"`, "1"),
    34  			Entry(`for "-"`, "-"),
    35  			Entry(`for "."`, "."),
    36  		)
    37  	})
    38  
    39  	Context("hashFNV", func() {
    40  		It("should hash the input", func() {
    41  			Expect(hashFNV("test")).To(Equal("afd071e5"))
    42  		})
    43  	})
    44  })