Skip to content

Commit

Permalink
chore: [CHAOS-4699]: added fuzz test for FuzzBuildContainerSpec (#215)
Browse files Browse the repository at this point in the history
Signed-off-by: Arkajyoti Mukherjee <[email protected]>
  • Loading branch information
arkajyotiMukherjee authored Apr 1, 2024
1 parent a8eaaa6 commit 2f3f2c4
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions pkg/utils/builders_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,37 @@ import (
"testing"
)

func FuzzBuildContainerSpec(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
fuzzConsumer := fuzz.NewConsumer(data)
targetStruct := &struct {
ExpDetails *ExperimentDetails
EnvVars []corev1.EnvVar
}{}

err := fuzzConsumer.GenerateStruct(targetStruct)
if err != nil {
return
}
containerSpec, err := buildContainerSpec(targetStruct.ExpDetails, targetStruct.EnvVars)
if err != nil {
return
}

container, err := containerSpec.Build()
if err != nil {
return
}

require.Equal(t, targetStruct.ExpDetails.JobName, container.Name)
require.Equal(t, targetStruct.ExpDetails.ExpImage, container.Image)
require.Equal(t, targetStruct.ExpDetails.ExpCommand, container.Command)
require.Equal(t, targetStruct.ExpDetails.ExpArgs, container.Args)
require.Equal(t, targetStruct.ExpDetails.ExpImagePullPolicy, container.ImagePullPolicy)
require.Equal(t, targetStruct.EnvVars, container.Env)
})
}

func FuzzGetEnvFromMap(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
fuzzConsumer := fuzz.NewConsumer(data)
Expand Down

0 comments on commit 2f3f2c4

Please sign in to comment.