Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Schuppert <[email protected]>
  • Loading branch information
stuggi committed Jul 3, 2024
1 parent 40bc013 commit 49173b1
Showing 1 changed file with 60 additions and 0 deletions.
60 changes: 60 additions & 0 deletions modules/common/webhook/rfc_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
Copyright 2024 Red Hat
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package webhook

import (
"testing"

"k8s.io/apimachinery/pkg/util/validation/field"

. "github.com/onsi/gomega"
)

func TestValidateDNS1123Label(t *testing.T) {
tests := []struct {
name string
keys []string
want bool
}{
{
name: "req is higher then min",
keys: []string{"123"},
want: false,
},
}

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
g := NewWithT(t)

p := field.NewPath("foo")

errs := ValidateDNS1123Label(p, tt.keys)

if tt.wantWarn {
g.Expect(warns).To(HaveLen(1))
} else {
g.Expect(warns).To(BeEmpty())
}
if tt.wantErr {
g.Expect(errs).To(HaveLen(1))
} else {
g.Expect(errs).To(BeEmpty())
}
})
}
}

0 comments on commit 49173b1

Please sign in to comment.