Switch to autoscaling.Scale internally

This commit is contained in:
Jordan Liggitt
2017-11-09 12:13:08 -05:00
parent d215d4bf8c
commit 9c1be33ee1
23 changed files with 197 additions and 293 deletions

View File

@@ -1750,70 +1750,6 @@ func TestValidateIngressStatusUpdate(t *testing.T) {
}
}
func TestValidateScale(t *testing.T) {
successCases := []extensions.Scale{
{
ObjectMeta: metav1.ObjectMeta{
Name: "frontend",
Namespace: metav1.NamespaceDefault,
},
Spec: extensions.ScaleSpec{
Replicas: 1,
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "frontend",
Namespace: metav1.NamespaceDefault,
},
Spec: extensions.ScaleSpec{
Replicas: 10,
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "frontend",
Namespace: metav1.NamespaceDefault,
},
Spec: extensions.ScaleSpec{
Replicas: 0,
},
},
}
for _, successCase := range successCases {
if errs := ValidateScale(&successCase); len(errs) != 0 {
t.Errorf("expected success: %v", errs)
}
}
errorCases := []struct {
scale extensions.Scale
msg string
}{
{
scale: extensions.Scale{
ObjectMeta: metav1.ObjectMeta{
Name: "frontend",
Namespace: metav1.NamespaceDefault,
},
Spec: extensions.ScaleSpec{
Replicas: -1,
},
},
msg: "must be greater than or equal to 0",
},
}
for _, c := range errorCases {
if errs := ValidateScale(&c.scale); len(errs) == 0 {
t.Errorf("expected failure for %s", c.msg)
} else if !strings.Contains(errs[0].Error(), c.msg) {
t.Errorf("unexpected error: %v, expected: %s", errs[0], c.msg)
}
}
}
func TestValidateReplicaSetStatus(t *testing.T) {
tests := []struct {
name string