Skip to content

Commit

Permalink
test: Adding fuzz test for getSetSidecarSecrets in builders.go
Browse files Browse the repository at this point in the history
  • Loading branch information
S-ayanide committed Mar 14, 2024
1 parent 3d2913e commit 90a4b4f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
26 changes: 26 additions & 0 deletions pkg/utils/builders_fuzz_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,29 @@ func FuzzGetEnvFromMap(f *testing.F) {
require.Equal(t, envCount, len(targetStruct.m)+1)
})
}

func FuzzSetSidecarSecrets(f *testing.F) {
f.Fuzz(func(t *testing.T, data []byte) {
fuzzConsumer := fuzz.NewConsumer(data)
targetStruct := &struct {
experiment *ExperimentDetails
}{}

err := fuzzConsumer.GenerateStruct(targetStruct)
if err != nil {
return
}
if targetStruct.experiment != nil {
secrets := setSidecarSecrets(targetStruct.experiment)
require.GreaterOrEqual(t, len(secrets), 1)

for _, sidecar := range targetStruct.experiment.SideCars {
for _, secret := range sidecar.Secrets {
for _, s := range secrets {
require.Equal(t, s.Name, secret.Name)
}
}
}
}
})
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
go test fuzz v1
[]byte("0")

0 comments on commit 90a4b4f

Please sign in to comment.