Skip to content

Commit

Permalink
Update controller e2e tests
Browse files Browse the repository at this point in the history
Signed-off-by: Sunny <[email protected]>
  • Loading branch information
darkowlzz committed Mar 12, 2024
1 parent 4c83ae6 commit 4a5e1d1
Show file tree
Hide file tree
Showing 6 changed files with 756 additions and 1,333 deletions.
2 changes: 1 addition & 1 deletion internal/controller/controllers_fuzzer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ import (
"github.com/fluxcd/pkg/runtime/testenv"
sourcev1 "github.com/fluxcd/source-controller/api/v1"

image_automationv1 "github.com/fluxcd/image-automation-controller/api/v1beta1"
image_automationv1 "github.com/fluxcd/image-automation-controller/api/v1beta2"
"github.com/fluxcd/image-automation-controller/pkg/update"
)

Expand Down
28 changes: 15 additions & 13 deletions internal/controller/imageupdateautomation_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,22 @@ limitations under the License.

package controller

import (
"testing"
// import (
// "testing"

fuzz "github.com/AdaLogics/go-fuzz-headers"
)
// fuzz "github.com/AdaLogics/go-fuzz-headers"

func Fuzz_templateMsg(f *testing.F) {
f.Add("template", []byte{})
f.Add("", []byte{})
// "github.com/fluxcd/image-automation-controller/internal/source"
// )

f.Fuzz(func(t *testing.T, template string, seed []byte) {
var values TemplateData
fuzz.NewConsumer(seed).GenerateStruct(&values)
// func Fuzz_templateMsg(f *testing.F) {
// f.Add("template", []byte{})
// f.Add("", []byte{})

_, _ = templateMsg(template, &values)
})
}
// f.Fuzz(func(t *testing.T, template string, seed []byte) {
// var values source.TemplateData
// fuzz.NewConsumer(seed).GenerateStruct(&values)

// _, _ = templateMsg(template, &values)
// })
// }
10 changes: 6 additions & 4 deletions internal/controller/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (

utilruntime "k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/tools/record"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"

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

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

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

controllerName := "image-automation-controller"
if err := (&ImageUpdateAutomationReconciler{
Client: testEnv,
EventRecorder: testEnv.GetEventRecorderFor(controllerName),
features: feats,
Client: testEnv,
EventRecorder: record.NewFakeRecorder(32),
features: feats,
ControllerName: controllerName,
}).SetupWithManager(ctx, testEnv, ImageUpdateAutomationReconcilerOptions{
RateLimiter: controller.GetDefaultRateLimiter(),
}); err != nil {
Expand Down
10 changes: 10 additions & 0 deletions internal/controller/testdata/pathconfig-expected/no/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: update-no
spec:
template:
spec:
containers:
- name: hello
image: helloworld:1.0.0 # SETTER_SITE
10 changes: 10 additions & 0 deletions internal/controller/testdata/pathconfig-expected/yes/deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: update-yes
spec:
template:
spec:
containers:
- name: hello
image: helloworld:1.0.1 # SETTER_SITE
Loading

0 comments on commit 4a5e1d1

Please sign in to comment.