Skip to content

chore: Updated test coverage for RecordReconcileReq func #1821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 37 additions & 1 deletion internal/reconcile/summarize/processor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"sigs.k8s.io/controller-runtime/pkg/client"

"github.com/fluxcd/pkg/apis/meta"

sourcev1 "github.com/fluxcd/source-controller/api/v1"
"github.com/fluxcd/source-controller/internal/object"
"github.com/fluxcd/source-controller/internal/reconcile"
Expand Down Expand Up @@ -65,6 +64,43 @@ func TestRecordReconcileReq(t *testing.T) {
t.Expect(obj).To(HaveStatusLastHandledReconcileAt("now"))
},
},
{
name: "empty reconcile annotation value",
beforeFunc: func(obj client.Object) {
annotations := map[string]string{
meta.ReconcileRequestAnnotation: "",
}
obj.SetAnnotations(annotations)
},
afterFunc: func(t *WithT, obj client.Object) {
t.Expect(obj).To(HaveStatusLastHandledReconcileAt(""))
},
},
{
name: "whitespace-only reconcile annotation value",
beforeFunc: func(obj client.Object) {
annotations := map[string]string{
meta.ReconcileRequestAnnotation: " ",
}
obj.SetAnnotations(annotations)
},
afterFunc: func(t *WithT, obj client.Object) {
t.Expect(obj).To(HaveStatusLastHandledReconcileAt(" "))
},
},
{
name: "reconcile annotation overwrites existing status value",
beforeFunc: func(obj client.Object) {
object.SetStatusLastHandledReconcileAt(obj, "old-value")
annotations := map[string]string{
meta.ReconcileRequestAnnotation: "new-value",
}
obj.SetAnnotations(annotations)
},
afterFunc: func(t *WithT, obj client.Object) {
t.Expect(obj).To(HaveStatusLastHandledReconcileAt("new-value"))
},
},
}

for _, tt := range tests {
Expand Down