mirror of
https://github.com/containers/podman.git
synced 2025-12-02 02:58:03 +08:00
fix(deps): update module github.com/onsi/gomega to v1.38.0
Signed-off-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This commit is contained in:
22
vendor/github.com/onsi/gomega/gstruct/fields.go
generated
vendored
22
vendor/github.com/onsi/gomega/gstruct/fields.go
generated
vendored
@@ -8,6 +8,7 @@ import (
|
||||
"reflect"
|
||||
"runtime/debug"
|
||||
"strings"
|
||||
"unicode"
|
||||
|
||||
"github.com/onsi/gomega/format"
|
||||
errorsutil "github.com/onsi/gomega/gstruct/errors"
|
||||
@@ -65,6 +66,7 @@ func MatchFields(options Options, fields Fields) types.GomegaMatcher {
|
||||
return &FieldsMatcher{
|
||||
Fields: fields,
|
||||
IgnoreExtras: options&IgnoreExtras != 0,
|
||||
IgnoreUnexportedExtras: options&IgnoreUnexportedExtras != 0,
|
||||
IgnoreMissing: options&IgnoreMissing != 0,
|
||||
}
|
||||
}
|
||||
@@ -75,6 +77,8 @@ type FieldsMatcher struct {
|
||||
|
||||
// Whether to ignore extra elements or consider it an error.
|
||||
IgnoreExtras bool
|
||||
// Whether to ignore unexported extra elements or consider it an error.
|
||||
IgnoreUnexportedExtras bool
|
||||
// Whether to ignore missing elements or consider it an error.
|
||||
IgnoreMissing bool
|
||||
|
||||
@@ -97,6 +101,14 @@ func (m *FieldsMatcher) Match(actual any) (success bool, err error) {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func isExported(fieldName string) bool {
|
||||
if fieldName == "" {
|
||||
return false
|
||||
}
|
||||
r := []rune(fieldName)[0]
|
||||
return unicode.IsUpper(r)
|
||||
}
|
||||
|
||||
func (m *FieldsMatcher) matchFields(actual any) (errs []error) {
|
||||
val := reflect.ValueOf(actual)
|
||||
typ := val.Type()
|
||||
@@ -116,13 +128,21 @@ func (m *FieldsMatcher) matchFields(actual any) (errs []error) {
|
||||
|
||||
matcher, expected := m.Fields[fieldName]
|
||||
if !expected {
|
||||
if m.IgnoreUnexportedExtras && !isExported(fieldName) {
|
||||
return nil
|
||||
}
|
||||
if !m.IgnoreExtras {
|
||||
return fmt.Errorf("unexpected field %s: %+v", fieldName, actual)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
field := val.Field(i).Interface()
|
||||
var field any
|
||||
if _, isIgnoreMatcher := matcher.(*IgnoreMatcher) ; isIgnoreMatcher {
|
||||
field = struct {}{} // the matcher does not care about the actual value
|
||||
} else {
|
||||
field = val.Field(i).Interface()
|
||||
}
|
||||
|
||||
match, err := matcher.Match(field)
|
||||
if err != nil {
|
||||
|
||||
4
vendor/github.com/onsi/gomega/gstruct/types.go
generated
vendored
4
vendor/github.com/onsi/gomega/gstruct/types.go
generated
vendored
@@ -12,4 +12,8 @@ const (
|
||||
//considered by the identifier function. All members that map to a given key must still match successfully
|
||||
//with the matcher that is provided for that key.
|
||||
AllowDuplicates
|
||||
//IgnoreUnexportedExtras tells the matcher to ignore extra unexported fields, rather than triggering a failure.
|
||||
//it is not possible to check the value of unexported fields, so this option is only useful when you want to
|
||||
//check every exported fields, but you don't care about extra unexported fields.
|
||||
IgnoreUnexportedExtras
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user