Skip to content

Commit a44d3d2

Browse files
committed
adding scenarions for processor_test.go
Signed-off-by: zhaque44 <[email protected]>
1 parent 71e6ca6 commit a44d3d2

File tree

1 file changed

+37
-1
lines changed

1 file changed

+37
-1
lines changed

internal/reconcile/summarize/processor_test.go

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"sigs.k8s.io/controller-runtime/pkg/client"
2727

2828
"github.com/fluxcd/pkg/apis/meta"
29-
3029
sourcev1 "github.com/fluxcd/source-controller/api/v1"
3130
"github.com/fluxcd/source-controller/internal/object"
3231
"github.com/fluxcd/source-controller/internal/reconcile"
@@ -65,6 +64,43 @@ func TestRecordReconcileReq(t *testing.T) {
6564
t.Expect(obj).To(HaveStatusLastHandledReconcileAt("now"))
6665
},
6766
},
67+
{
68+
name: "empty reconcile annotation value",
69+
beforeFunc: func(obj client.Object) {
70+
annotations := map[string]string{
71+
meta.ReconcileRequestAnnotation: "",
72+
}
73+
obj.SetAnnotations(annotations)
74+
},
75+
afterFunc: func(t *WithT, obj client.Object) {
76+
t.Expect(obj).To(HaveStatusLastHandledReconcileAt(""))
77+
},
78+
},
79+
{
80+
name: "whitespace-only reconcile annotation value",
81+
beforeFunc: func(obj client.Object) {
82+
annotations := map[string]string{
83+
meta.ReconcileRequestAnnotation: " ",
84+
}
85+
obj.SetAnnotations(annotations)
86+
},
87+
afterFunc: func(t *WithT, obj client.Object) {
88+
t.Expect(obj).To(HaveStatusLastHandledReconcileAt(" "))
89+
},
90+
},
91+
{
92+
name: "reconcile annotation overwrites existing status value",
93+
beforeFunc: func(obj client.Object) {
94+
object.SetStatusLastHandledReconcileAt(obj, "old-value")
95+
annotations := map[string]string{
96+
meta.ReconcileRequestAnnotation: "new-value",
97+
}
98+
obj.SetAnnotations(annotations)
99+
},
100+
afterFunc: func(t *WithT, obj client.Object) {
101+
t.Expect(obj).To(HaveStatusLastHandledReconcileAt("new-value"))
102+
},
103+
},
68104
}
69105

70106
for _, tt := range tests {

0 commit comments

Comments
 (0)