Impose length limit when concatenating revision history

This commit is contained in:
Ted Yu
2019-05-08 10:14:16 -07:00
committed by Ted Yu
parent 22b6c69983
commit 9546fd540e
3 changed files with 30 additions and 9 deletions

View File

@@ -1274,13 +1274,19 @@ func TestAnnotationUtils(t *testing.T) {
//Test Case 1: Check if anotations are copied properly from deployment to RS
t.Run("SetNewReplicaSetAnnotations", func(t *testing.T) {
//Try to set the increment revision from 1 through 20
for i := 0; i < 20; i++ {
//Try to set the increment revision from 11 through 20
for i := 10; i < 20; i++ {
nextRevision := fmt.Sprintf("%d", i+1)
SetNewReplicaSetAnnotations(&tDeployment, &tRS, nextRevision, true)
SetNewReplicaSetAnnotations(&tDeployment, &tRS, nextRevision, true, 5)
//Now the ReplicaSets Revision Annotation should be i+1
if i >= 12 {
expectedHistoryAnnotation := fmt.Sprintf("%d,%d", i-1, i)
if tRS.Annotations[RevisionHistoryAnnotation] != expectedHistoryAnnotation {
t.Errorf("Revision History Expected=%s Obtained=%s", expectedHistoryAnnotation, tRS.Annotations[RevisionHistoryAnnotation])
}
}
if tRS.Annotations[RevisionAnnotation] != nextRevision {
t.Errorf("Revision Expected=%s Obtained=%s", nextRevision, tRS.Annotations[RevisionAnnotation])
}