refactor: consolidate common controller code
CI / image check (pull_request) Successful in 5s
CI / install-dependencies (pull_request) Successful in 6m57s
CI / build check (pull_request) Successful in 24s
CI / check format (pull_request) Successful in 22s
CI / check lint (pull_request) Successful in 22s
CI / test (pull_request) Successful in 2m24s
CI / image check (pull_request) Successful in 5s
CI / install-dependencies (pull_request) Successful in 6m57s
CI / build check (pull_request) Successful in 24s
CI / check format (pull_request) Successful in 22s
CI / check lint (pull_request) Successful in 22s
CI / test (pull_request) Successful in 2m24s
This commit is contained in:
@@ -198,20 +198,6 @@ func TestController_syncHandler_notFound(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestController_enqueuePolicyBinding(t *testing.T) {
|
||||
server := newAuthentikTestServer(t, authentikTestHandlers{})
|
||||
t.Cleanup(server.Close)
|
||||
|
||||
ctrl, _, cancel := newTestController(t, testPolicyBinding(), server.URL)
|
||||
t.Cleanup(cancel)
|
||||
|
||||
ctrl.enqueuePolicyBinding(testPolicyBinding())
|
||||
|
||||
if ctrl.workqueue.Len() != 1 {
|
||||
t.Fatalf("workqueue length = %d, want 1", ctrl.workqueue.Len())
|
||||
}
|
||||
}
|
||||
|
||||
// --- test helpers ---
|
||||
|
||||
func testPolicyBinding() *v1alpha1.PolicyBinding {
|
||||
@@ -232,7 +218,7 @@ func testPolicyBinding() *v1alpha1.PolicyBinding {
|
||||
}
|
||||
}
|
||||
|
||||
func newTestController(t *testing.T, pb *v1alpha1.PolicyBinding, authentikURL string) (*Controller, context.Context, context.CancelFunc) {
|
||||
func newTestController(t *testing.T, pb *v1alpha1.PolicyBinding, authentikURL string) (*PolicyBindingController, context.Context, context.CancelFunc) {
|
||||
t.Helper()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctrl, _, stop := newTestControllerWithContext(t, ctx, pb, authentikURL)
|
||||
@@ -242,7 +228,7 @@ func newTestController(t *testing.T, pb *v1alpha1.PolicyBinding, authentikURL st
|
||||
}
|
||||
}
|
||||
|
||||
func newTestControllerWithContext(t *testing.T, ctx context.Context, pb *v1alpha1.PolicyBinding, authentikURL string) (*Controller, context.Context, func()) {
|
||||
func newTestControllerWithContext(t *testing.T, ctx context.Context, pb *v1alpha1.PolicyBinding, authentikURL string) (*PolicyBindingController, context.Context, func()) {
|
||||
t.Helper()
|
||||
|
||||
authentikClient := newAuthentikAPIClientForTest(t, authentikURL)
|
||||
@@ -350,7 +336,7 @@ func writeJSON(t *testing.T, w http.ResponseWriter, status int, body any) {
|
||||
}
|
||||
}
|
||||
|
||||
func getPolicyBinding(t *testing.T, ctrl *Controller, namespace, name string) *v1alpha1.PolicyBinding {
|
||||
func getPolicyBinding(t *testing.T, ctrl *PolicyBindingController, namespace, name string) *v1alpha1.PolicyBinding {
|
||||
t.Helper()
|
||||
|
||||
got, err := ctrl.policyBindingClientset.PolicyBindingV1alpha1().PolicyBindings(namespace).Get(
|
||||
|
||||
Reference in New Issue
Block a user