Skip to content

Commit

Permalink
add test for label validation
Browse files Browse the repository at this point in the history
  • Loading branch information
pddg committed Aug 23, 2018
1 parent fce0d6b commit d4025c5
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions machines_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,40 @@ func TestIsValidRole(t *testing.T) {
}
}

func TestIsValidLabelName(t *testing.T) {
t.Parallel()

validNames := []string{"valid_name1", "valid-name2", "valid/name3"}
for _, vn := range validNames {
if !IsValidLabelName(vn) {
t.Error("validator should return true:", vn)
}
}
invalidNames := []string{"^in;valid name\\1", "in$valid#name&2", "invalid@name=3"}
for _, ivn := range invalidNames {
if IsValidLabelName(ivn) {
t.Error("validator should return false:", ivn)
}
}
}

func TestIsValidLabelValue(t *testing.T) {
t.Parallel()

validVals := []string{"^valid value@1", "valid$value-=2", "%valid':value;3"}
for _, vv := range validVals {
if !IsValidLabelValue(vv) {
t.Error("validator should return true:", vv)
}
}
invalidVals := []string{`inválidvaluõ1`, `iñvalidvålue`}
for _, ivv := range invalidVals {
if IsValidLabelValue(ivv) {
t.Error("validator should return false:", ivv)
}
}
}

func TestMachine(t *testing.T) {
t.Parallel()

Expand Down

0 comments on commit d4025c5

Please sign in to comment.