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:
@@ -220,20 +220,6 @@ func TestController_syncHandler_invalidPK(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestController_enqueueApplication(t *testing.T) {
|
||||
server := newAuthentikTestServer(t, authentikTestHandlers{})
|
||||
t.Cleanup(server.Close)
|
||||
|
||||
ctrl, _, cancel := newTestController(t, testApplication(), server.URL)
|
||||
t.Cleanup(cancel)
|
||||
|
||||
ctrl.enqueueApplication(testApplication())
|
||||
|
||||
if ctrl.workqueue.Len() != 1 {
|
||||
t.Fatalf("workqueue length = %d, want 1", ctrl.workqueue.Len())
|
||||
}
|
||||
}
|
||||
|
||||
// --- test helpers ---
|
||||
|
||||
func testApplication() *v1alpha1.Application {
|
||||
@@ -254,7 +240,7 @@ func testApplication() *v1alpha1.Application {
|
||||
}
|
||||
}
|
||||
|
||||
func newTestController(t *testing.T, app *v1alpha1.Application, authentikURL string) (*Controller, context.Context, context.CancelFunc) {
|
||||
func newTestController(t *testing.T, app *v1alpha1.Application, authentikURL string) (*ApplicationController, context.Context, context.CancelFunc) {
|
||||
t.Helper()
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
ctrl, _, stop := newTestControllerWithContext(t, ctx, app, authentikURL)
|
||||
@@ -264,7 +250,7 @@ func newTestController(t *testing.T, app *v1alpha1.Application, authentikURL str
|
||||
}
|
||||
}
|
||||
|
||||
func newTestControllerWithContext(t *testing.T, ctx context.Context, app *v1alpha1.Application, authentikURL string) (*Controller, context.Context, func()) {
|
||||
func newTestControllerWithContext(t *testing.T, ctx context.Context, app *v1alpha1.Application, authentikURL string) (*ApplicationController, context.Context, func()) {
|
||||
t.Helper()
|
||||
|
||||
authentikClient := newAuthentikAPIClientForTest(t, authentikURL)
|
||||
@@ -382,7 +368,7 @@ func writeJSON(t *testing.T, w http.ResponseWriter, status int, body any) {
|
||||
}
|
||||
}
|
||||
|
||||
func getApplication(t *testing.T, ctrl *Controller, namespace, name string) *v1alpha1.Application {
|
||||
func getApplication(t *testing.T, ctrl *ApplicationController, namespace, name string) *v1alpha1.Application {
|
||||
t.Helper()
|
||||
|
||||
got, err := ctrl.applicationClientset.ApplicationV1alpha1().Applications(namespace).Get(
|
||||
|
||||
Reference in New Issue
Block a user