Skip to content

Commit cdb9a89

Browse files
committed
test: Use slices.Contains
1 parent 4253081 commit cdb9a89

File tree

1 file changed

+2
-11
lines changed

1 file changed

+2
-11
lines changed

pkg/config/json_test.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,12 @@ import (
44
"encoding/json"
55
"fmt"
66
"reflect"
7+
"slices"
78
"testing"
89

910
"github.com/stretchr/testify/require"
1011
)
1112

12-
func contains(strings []string, val string) bool {
13-
for _, str := range strings {
14-
if val == str {
15-
return true
16-
}
17-
}
18-
19-
return false
20-
}
21-
2213
// This sets all the fields of the `obj` struct to non-empty values.
2314
// This will be used to test JSON serialization as extensively as possible to
2415
// avoid breaking backwards compatibility.
@@ -34,7 +25,7 @@ func fillStruct(t *testing.T, obj interface{}, skipFields []string) {
3425
fieldVal := val.FieldByIndex(e.Index)
3526
typeName := val.Type().Name()
3627

37-
if contains(skipFields, field.Name) {
28+
if slices.Contains(skipFields, field.Name) {
3829
continue
3930
}
4031
switch fieldVal.Kind() {

0 commit comments

Comments
 (0)