Skip to content

Commit 3d2913e

Browse files
authored
test: Adding fuzz test for getEnvFromMap in builders.go (#213)
1 parent f7b569a commit 3d2913e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

pkg/utils/builders_fuzz_test.go

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package utils
2+
3+
import (
4+
fuzz "github.com/AdaLogics/go-fuzz-headers"
5+
"github.com/stretchr/testify/require"
6+
corev1 "k8s.io/api/core/v1"
7+
"testing"
8+
)
9+
10+
func FuzzGetEnvFromMap(f *testing.F) {
11+
f.Fuzz(func(t *testing.T, data []byte) {
12+
fuzzConsumer := fuzz.NewConsumer(data)
13+
targetStruct := &struct {
14+
m map[string]corev1.EnvVar
15+
}{}
16+
err := fuzzConsumer.GenerateStruct(targetStruct)
17+
if err != nil {
18+
return
19+
}
20+
envs := getEnvFromMap(targetStruct.m)
21+
var envCount = len(envs)
22+
require.Equal(t, envCount, len(targetStruct.m)+1)
23+
})
24+
}

0 commit comments

Comments
 (0)