@@ -6678,8 +6678,6 @@ func TestMigrateStatus(t *testing.T) {
66786678}
66796679
66806680func TestApplicationSetOwnsHandlerUpdate (t * testing.T ) {
6681- ownsHandler := getApplicationSetOwnsHandler ()
6682-
66836681 buildAppSet := func (annotations map [string ]string ) * v1alpha1.ApplicationSet {
66846682 return & v1alpha1.ApplicationSet {
66856683 ObjectMeta : metav1.ObjectMeta {
@@ -6689,10 +6687,11 @@ func TestApplicationSetOwnsHandlerUpdate(t *testing.T) {
66896687 }
66906688
66916689 tests := []struct {
6692- name string
6693- appSetOld crtclient.Object
6694- appSetNew crtclient.Object
6695- want bool
6690+ name string
6691+ appSetOld crtclient.Object
6692+ appSetNew crtclient.Object
6693+ enableProgressiveSyncs bool
6694+ want bool
66966695 }{
66976696 {
66986697 name : "Different Spec" ,
@@ -6710,13 +6709,15 @@ func TestApplicationSetOwnsHandlerUpdate(t *testing.T) {
67106709 },
67116710 },
67126711 },
6713- want : true ,
6712+ enableProgressiveSyncs : false ,
6713+ want : true ,
67146714 },
67156715 {
6716- name : "Different Annotations" ,
6717- appSetOld : buildAppSet (map [string ]string {"key1" : "value1" }),
6718- appSetNew : buildAppSet (map [string ]string {"key1" : "value2" }),
6719- want : true ,
6716+ name : "Different Annotations" ,
6717+ appSetOld : buildAppSet (map [string ]string {"key1" : "value1" }),
6718+ appSetNew : buildAppSet (map [string ]string {"key1" : "value2" }),
6719+ enableProgressiveSyncs : false ,
6720+ want : true ,
67206721 },
67216722 {
67226723 name : "Different Labels" ,
@@ -6730,7 +6731,8 @@ func TestApplicationSetOwnsHandlerUpdate(t *testing.T) {
67306731 Labels : map [string ]string {"key1" : "value2" },
67316732 },
67326733 },
6733- want : true ,
6734+ enableProgressiveSyncs : false ,
6735+ want : true ,
67346736 },
67356737 {
67366738 name : "Different Finalizers" ,
@@ -6744,7 +6746,8 @@ func TestApplicationSetOwnsHandlerUpdate(t *testing.T) {
67446746 Finalizers : []string {"finalizer2" },
67456747 },
67466748 },
6747- want : true ,
6749+ enableProgressiveSyncs : false ,
6750+ want : true ,
67486751 },
67496752 {
67506753 name : "No Changes" ,
@@ -6772,15 +6775,17 @@ func TestApplicationSetOwnsHandlerUpdate(t *testing.T) {
67726775 Finalizers : []string {"finalizer1" },
67736776 },
67746777 },
6775- want : false ,
6778+ enableProgressiveSyncs : false ,
6779+ want : false ,
67766780 },
67776781 {
67786782 name : "annotation removed" ,
67796783 appSetOld : buildAppSet (map [string ]string {
67806784 argocommon .AnnotationApplicationSetRefresh : "true" ,
67816785 }),
6782- appSetNew : buildAppSet (map [string ]string {}),
6783- want : false ,
6786+ appSetNew : buildAppSet (map [string ]string {}),
6787+ enableProgressiveSyncs : false ,
6788+ want : false ,
67846789 },
67856790 {
67866791 name : "annotation not removed" ,
@@ -6790,43 +6795,48 @@ func TestApplicationSetOwnsHandlerUpdate(t *testing.T) {
67906795 appSetNew : buildAppSet (map [string ]string {
67916796 argocommon .AnnotationApplicationSetRefresh : "true" ,
67926797 }),
6793- want : false ,
6798+ enableProgressiveSyncs : false ,
6799+ want : false ,
67946800 },
67956801 {
67966802 name : "annotation added" ,
67976803 appSetOld : buildAppSet (map [string ]string {}),
67986804 appSetNew : buildAppSet (map [string ]string {
67996805 argocommon .AnnotationApplicationSetRefresh : "true" ,
68006806 }),
6801- want : true ,
6807+ enableProgressiveSyncs : false ,
6808+ want : true ,
68026809 },
68036810 {
6804- name : "old object is not an appset" ,
6805- appSetOld : & v1alpha1.Application {},
6806- appSetNew : buildAppSet (map [string ]string {}),
6807- want : false ,
6811+ name : "old object is not an appset" ,
6812+ appSetOld : & v1alpha1.Application {},
6813+ appSetNew : buildAppSet (map [string ]string {}),
6814+ enableProgressiveSyncs : false ,
6815+ want : false ,
68086816 },
68096817 {
6810- name : "new object is not an appset" ,
6811- appSetOld : buildAppSet (map [string ]string {}),
6812- appSetNew : & v1alpha1.Application {},
6813- want : false ,
6818+ name : "new object is not an appset" ,
6819+ appSetOld : buildAppSet (map [string ]string {}),
6820+ appSetNew : & v1alpha1.Application {},
6821+ enableProgressiveSyncs : false ,
6822+ want : false ,
68146823 },
68156824 }
68166825
68176826 for _ , tt := range tests {
68186827 t .Run (tt .name , func (t * testing.T ) {
6828+ ownsHandler := getApplicationSetOwnsHandler (tt .enableProgressiveSyncs )
68196829 requeue := ownsHandler .UpdateFunc (event.UpdateEvent {
68206830 ObjectOld : tt .appSetOld ,
68216831 ObjectNew : tt .appSetNew ,
68226832 })
6823- assert .Equalf (t , tt .want , requeue , "ownsHandler.UpdateFunc(%v, %v)" , tt .appSetOld , tt .appSetNew )
6833+ assert .Equalf (t , tt .want , requeue , "ownsHandler.UpdateFunc(%v, %v, %t )" , tt .appSetOld , tt .appSetNew , tt . enableProgressiveSyncs )
68246834 })
68256835 }
68266836}
68276837
68286838func TestApplicationSetOwnsHandlerGeneric (t * testing.T ) {
6829- ownsHandler := getApplicationSetOwnsHandler ()
6839+ ownsHandler := getApplicationSetOwnsHandler (false )
68306840 tests := []struct {
68316841 name string
68326842 obj crtclient.Object
@@ -6855,7 +6865,7 @@ func TestApplicationSetOwnsHandlerGeneric(t *testing.T) {
68556865}
68566866
68576867func TestApplicationSetOwnsHandlerCreate (t * testing.T ) {
6858- ownsHandler := getApplicationSetOwnsHandler ()
6868+ ownsHandler := getApplicationSetOwnsHandler (false )
68596869 tests := []struct {
68606870 name string
68616871 obj crtclient.Object
@@ -6884,7 +6894,7 @@ func TestApplicationSetOwnsHandlerCreate(t *testing.T) {
68846894}
68856895
68866896func TestApplicationSetOwnsHandlerDelete (t * testing.T ) {
6887- ownsHandler := getApplicationSetOwnsHandler ()
6897+ ownsHandler := getApplicationSetOwnsHandler (false )
68886898 tests := []struct {
68896899 name string
68906900 obj crtclient.Object
@@ -6914,19 +6924,55 @@ func TestApplicationSetOwnsHandlerDelete(t *testing.T) {
69146924
69156925func TestShouldRequeueForApplicationSet (t * testing.T ) {
69166926 type args struct {
6917- appSetOld * v1alpha1.ApplicationSet
6918- appSetNew * v1alpha1.ApplicationSet
6927+ appSetOld * v1alpha1.ApplicationSet
6928+ appSetNew * v1alpha1.ApplicationSet
6929+ enableProgressiveSyncs bool
69196930 }
69206931 tests := []struct {
69216932 name string
69226933 args args
69236934 want bool
69246935 }{
6925- {name : "NilAppSet" , args : args {appSetNew : & v1alpha1.ApplicationSet {}, appSetOld : nil }, want : false },
6936+ {
6937+ name : "NilAppSet" ,
6938+ args : args {
6939+ appSetNew : & v1alpha1.ApplicationSet {},
6940+ appSetOld : nil ,
6941+ enableProgressiveSyncs : false ,
6942+ },
6943+ want : false ,
6944+ },
6945+ {
6946+ name : "ApplicationSetApplicationStatusChanged" ,
6947+ args : args {
6948+ appSetOld : & v1alpha1.ApplicationSet {
6949+ Status : v1alpha1.ApplicationSetStatus {
6950+ ApplicationStatus : []v1alpha1.ApplicationSetApplicationStatus {
6951+ {
6952+ Application : "app1" ,
6953+ Status : "Healthy" ,
6954+ },
6955+ },
6956+ },
6957+ },
6958+ appSetNew : & v1alpha1.ApplicationSet {
6959+ Status : v1alpha1.ApplicationSetStatus {
6960+ ApplicationStatus : []v1alpha1.ApplicationSetApplicationStatus {
6961+ {
6962+ Application : "app1" ,
6963+ Status : "Waiting" ,
6964+ },
6965+ },
6966+ },
6967+ },
6968+ enableProgressiveSyncs : true ,
6969+ },
6970+ want : true ,
6971+ },
69266972 }
69276973 for _ , tt := range tests {
69286974 t .Run (tt .name , func (t * testing.T ) {
6929- assert .Equalf (t , tt .want , shouldRequeueForApplicationSet (tt .args .appSetOld , tt .args .appSetNew ), "shouldRequeueForApplicationSet(%v, %v)" , tt .args .appSetOld , tt .args .appSetNew )
6975+ assert .Equalf (t , tt .want , shouldRequeueForApplicationSet (tt .args .appSetOld , tt .args .appSetNew , tt . args . enableProgressiveSyncs ), "shouldRequeueForApplicationSet(%v, %v)" , tt .args .appSetOld , tt .args .appSetNew )
69306976 })
69316977 }
69326978}
0 commit comments