@@ -29,6 +29,7 @@ import (
2929
3030 "sigs.k8s.io/controller-runtime/pkg/config"
3131 "sigs.k8s.io/controller-runtime/pkg/controller"
32+ "sigs.k8s.io/controller-runtime/pkg/controller/priorityqueue"
3233 "sigs.k8s.io/controller-runtime/pkg/event"
3334 "sigs.k8s.io/controller-runtime/pkg/handler"
3435 internalcontroller "sigs.k8s.io/controller-runtime/pkg/internal/controller"
@@ -437,5 +438,41 @@ var _ = Describe("controller.Controller", func() {
437438 _ , ok := c .(manager.LeaderElectionRunnable )
438439 Expect (ok ).To (BeTrue ())
439440 })
441+
442+ It ("should configure a priority queue if UsePriorityQueue is set" , func () {
443+ m , err := manager .New (cfg , manager.Options {
444+ Controller : config.Controller {UsePriorityQueue : true },
445+ })
446+ Expect (err ).NotTo (HaveOccurred ())
447+
448+ c , err := controller .New ("new-controller-16" , m , controller.Options {
449+ Reconciler : rec ,
450+ })
451+ Expect (err ).NotTo (HaveOccurred ())
452+
453+ ctrl , ok := c .(* internalcontroller.Controller [reconcile.Request ])
454+ Expect (ok ).To (BeTrue ())
455+
456+ q := ctrl .NewQueue ("foo" , nil )
457+ _ , ok = q .(priorityqueue.PriorityQueue [reconcile.Request ])
458+ Expect (ok ).To (BeTrue ())
459+ })
460+
461+ It ("should not configure a priority queue if UsePriorityQueue is not set" , func () {
462+ m , err := manager .New (cfg , manager.Options {})
463+ Expect (err ).NotTo (HaveOccurred ())
464+
465+ c , err := controller .New ("new-controller-17" , m , controller.Options {
466+ Reconciler : rec ,
467+ })
468+ Expect (err ).NotTo (HaveOccurred ())
469+
470+ ctrl , ok := c .(* internalcontroller.Controller [reconcile.Request ])
471+ Expect (ok ).To (BeTrue ())
472+
473+ q := ctrl .NewQueue ("foo" , nil )
474+ _ , ok = q .(priorityqueue.PriorityQueue [reconcile.Request ])
475+ Expect (ok ).To (BeFalse ())
476+ })
440477 })
441478})
0 commit comments