Fix coordination.Lease validation
This commit is contained in:
@@ -71,6 +71,10 @@ func TestValidateLeaseSpecUpdate(t *testing.T) {
|
||||
oldLeaseDuration := int32(3)
|
||||
oldLeaseTransitions := int32(3)
|
||||
oldLease := &coordination.Lease{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: "holder",
|
||||
Namespace: "holder-namespace",
|
||||
},
|
||||
Spec: coordination.LeaseSpec{
|
||||
HolderIdentity: &oldHolder,
|
||||
LeaseDurationSeconds: &oldLeaseDuration,
|
||||
@@ -78,7 +82,23 @@ func TestValidateLeaseSpecUpdate(t *testing.T) {
|
||||
},
|
||||
}
|
||||
errs := ValidateLeaseUpdate(lease, oldLease)
|
||||
if len(errs) != 2 {
|
||||
if len(errs) != 3 {
|
||||
t.Errorf("unexpected list of errors: %#v", errs.ToAggregate().Error())
|
||||
}
|
||||
|
||||
validLeaseDuration := int32(10)
|
||||
validLeaseTransitions := int32(20)
|
||||
validLease := &coordination.Lease{
|
||||
ObjectMeta: oldLease.ObjectMeta,
|
||||
Spec: coordination.LeaseSpec{
|
||||
HolderIdentity: &holder,
|
||||
LeaseDurationSeconds: &validLeaseDuration,
|
||||
LeaseTransitions: &validLeaseTransitions,
|
||||
},
|
||||
}
|
||||
validLease.ObjectMeta.ResourceVersion = "2"
|
||||
errs = ValidateLeaseUpdate(validLease, oldLease)
|
||||
if len(errs) != 0 {
|
||||
t.Errorf("unexpected list of errors for valid update: %#v", errs.ToAggregate().Error())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user