Add a few extra test cases for API validation of labels that would have

caught a bug that was in past versions. Also, copy the label key format
requirements from the API types.go comments into the labels doc.
This commit is contained in:
Alex Robinson
2015-02-04 22:21:34 +00:00
parent b852cd2c80
commit 6bb374ca54
2 changed files with 53 additions and 0 deletions

View File

@@ -876,6 +876,26 @@ func TestValidatePodUpdate(t *testing.T) {
false,
"port change",
},
{
api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{
"foo": "bar",
},
},
},
api.Pod{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{
"Bar": "foo",
},
},
},
true,
"bad label change",
},
}
for _, test := range tests {
@@ -1640,6 +1660,17 @@ func TestValidateMinionUpdate(t *testing.T) {
Labels: map[string]string{"bar": "fooobaz"},
},
}, true},
{api.Node{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{"foo": "baz"},
},
}, api.Node{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{"Foo": "baz"},
},
}, false},
}
for i, test := range tests {
errs := ValidateMinionUpdate(&test.oldMinion, &test.minion)
@@ -1796,6 +1827,19 @@ func TestValidateServiceUpdate(t *testing.T) {
PortalIP: "127.0.0.2",
},
}, false},
{ // 10
api.Service{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{"foo": "baz"},
},
},
api.Service{
ObjectMeta: api.ObjectMeta{
Name: "foo",
Labels: map[string]string{"Foo": "baz"},
},
}, false},
}
for i, test := range tests {
errs := ValidateServiceUpdate(&test.oldService, &test.service)