...
1
16
17 package selector_test
18
19 import (
20 . "github.com/onsi/ginkgo/v2"
21 . "github.com/onsi/gomega"
22 "k8s.io/apimachinery/pkg/fields"
23
24 . "sigs.k8s.io/controller-runtime/pkg/internal/field/selector"
25 )
26
27 var _ = Describe("RequiresExactMatch function", func() {
28
29 It("Returns false when the selector matches everything", func() {
30 requiresExactMatch := RequiresExactMatch(fields.Everything())
31 Expect(requiresExactMatch).To(BeFalse())
32 })
33
34 It("Returns false when the selector matches nothing", func() {
35 requiresExactMatch := RequiresExactMatch(fields.Nothing())
36 Expect(requiresExactMatch).To(BeFalse())
37 })
38
39 It("Returns false when the selector has the form key!=val", func() {
40 requiresExactMatch := RequiresExactMatch(fields.ParseSelectorOrDie("key!=val"))
41 Expect(requiresExactMatch).To(BeFalse())
42 })
43
44 It("Returns true when the selector has the form key1==val1,key2==val2", func() {
45 requiresExactMatch := RequiresExactMatch(fields.ParseSelectorOrDie("key1==val1,key2==val2"))
46 Expect(requiresExactMatch).To(BeTrue())
47 })
48
49 It("Returns true when the selector has the form key==val", func() {
50 requiresExactMatch := RequiresExactMatch(fields.ParseSelectorOrDie("key==val"))
51 Expect(requiresExactMatch).To(BeTrue())
52 })
53
54 It("Returns true when the selector has the form key=val", func() {
55 requiresExactMatch := RequiresExactMatch(fields.ParseSelectorOrDie("key=val"))
56 Expect(requiresExactMatch).To(BeTrue())
57 })
58 })
59
View as plain text