mirror of https://github.com/fluxcd/flux2.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
803 B
Go
56 lines
803 B
Go
3 years ago
|
package main
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
"k8s.io/apimachinery/pkg/util/rand"
|
||
|
)
|
||
|
|
||
|
func Test_validateObjectName(t *testing.T) {
|
||
|
tests := []struct {
|
||
|
name string
|
||
|
valid bool
|
||
|
}{
|
||
|
{
|
||
|
name: "flux-system",
|
||
|
valid: true,
|
||
|
},
|
||
|
{
|
||
|
name: "-flux-system",
|
||
|
valid: false,
|
||
|
},
|
||
|
{
|
||
|
name: "-flux-system-",
|
||
|
valid: false,
|
||
|
},
|
||
|
{
|
||
|
name: "third.first",
|
||
|
valid: false,
|
||
|
},
|
||
|
{
|
||
|
name: "THirdfirst",
|
||
|
valid: false,
|
||
|
},
|
||
|
{
|
||
|
name: "THirdfirst",
|
||
|
valid: false,
|
||
|
},
|
||
|
{
|
||
|
name: rand.String(63),
|
||
|
valid: true,
|
||
|
},
|
||
|
{
|
||
|
name: rand.String(64),
|
||
|
valid: false,
|
||
|
},
|
||
|
}
|
||
|
|
||
|
for _, tt := range tests {
|
||
|
valid := validateObjectName(tt.name)
|
||
|
if valid != tt.valid {
|
||
|
t.Errorf("expected name %q to return %t for validateObjectName func but got %t",
|
||
|
tt.name, tt.valid, valid)
|
||
|
}
|
||
|
}
|
||
|
}
|