Skip to content

Commit 6c327e7

Browse files
committed
Update controller e2e tests
Rewrite the controller tests to test the new behavior of the reconciler and also simplify the tests for scenarios that are now being tests in internal/source package, especially the git operations related tests. Some of the old controller tests are still kept to ensure those functionalities continue to work after the controller rewrite, even if some of them are redundant. They can be removed in the future for the tests in the respective subpackages, internal/policy and internal/source. New tests that focus the status conditions and notifications have been added for various possible scenarios. The test helpers have been modified to simplify their usage and some have been replaced with their equivalent version from the testutils package. Signed-off-by: Sunny <[email protected]>
1 parent ed5aa93 commit 6c327e7

File tree

7 files changed

+1261
-1349
lines changed

7 files changed

+1261
-1349
lines changed

internal/controller/controllers_fuzzer_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import (
5757
"github.com/fluxcd/pkg/runtime/testenv"
5858
sourcev1 "github.com/fluxcd/source-controller/api/v1"
5959

60-
image_automationv1 "github.com/fluxcd/image-automation-controller/api/v1beta1"
60+
image_automationv1 "github.com/fluxcd/image-automation-controller/api/v1beta2"
6161
"github.com/fluxcd/image-automation-controller/pkg/update"
6262
)
6363

internal/controller/imageupdateautomation_controller_test.go

-35
This file was deleted.

internal/controller/suite_test.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626

2727
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
2828
"k8s.io/client-go/kubernetes/scheme"
29+
"k8s.io/client-go/tools/record"
2930
ctrl "sigs.k8s.io/controller-runtime"
3031
"sigs.k8s.io/controller-runtime/pkg/client"
3132

@@ -34,7 +35,7 @@ import (
3435
"github.com/fluxcd/pkg/runtime/testenv"
3536
sourcev1 "github.com/fluxcd/source-controller/api/v1"
3637

37-
imagev1 "github.com/fluxcd/image-automation-controller/api/v1beta1"
38+
imagev1 "github.com/fluxcd/image-automation-controller/api/v1beta2"
3839
// +kubebuilder:scaffold:imports
3940
)
4041

@@ -85,9 +86,10 @@ func runTestsWithFeatures(m *testing.M, feats map[string]bool) int {
8586

8687
controllerName := "image-automation-controller"
8788
if err := (&ImageUpdateAutomationReconciler{
88-
Client: testEnv,
89-
EventRecorder: testEnv.GetEventRecorderFor(controllerName),
90-
features: feats,
89+
Client: testEnv,
90+
EventRecorder: record.NewFakeRecorder(32),
91+
features: feats,
92+
ControllerName: controllerName,
9193
}).SetupWithManager(ctx, testEnv, ImageUpdateAutomationReconcilerOptions{
9294
RateLimiter: controller.GetDefaultRateLimiter(),
9395
}); err != nil {

internal/controller/testdata/appconfig-expected/deploy.yaml

-10
This file was deleted.

internal/controller/testdata/appconfig-expected2/deploy.yaml

-10
This file was deleted.

internal/controller/testdata/brokenlink/bar.yaml

-1
This file was deleted.

0 commit comments

Comments
 (0)