mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 16:29:21 +00:00
add support for equality check.
This commit is contained in:
parent
9bbdbc510e
commit
df9620c9f6
@ -77,7 +77,10 @@ func (v *ObjectVal) ConvertToType(typeValue ref.Type) ref.Val {
|
|||||||
|
|
||||||
// Equal returns true if the `other` value has the same type and content as the implementing struct.
|
// Equal returns true if the `other` value has the same type and content as the implementing struct.
|
||||||
func (v *ObjectVal) Equal(other ref.Val) ref.Val {
|
func (v *ObjectVal) Equal(other ref.Val) ref.Val {
|
||||||
return types.Bool(v == other)
|
if rhs, ok := other.(*ObjectVal); ok {
|
||||||
|
return types.Bool(reflect.DeepEqual(v.fields, rhs.fields))
|
||||||
|
}
|
||||||
|
return types.Bool(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type returns the TypeValue of the value.
|
// Type returns the TypeValue of the value.
|
||||||
|
@ -101,6 +101,11 @@ func TestTypeProvider(t *testing.T) {
|
|||||||
}.intList.sum()`,
|
}.intList.sum()`,
|
||||||
expectedValue: int64(6),
|
expectedValue: int64(6),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "equality check",
|
||||||
|
expression: "Object{spec: Object.spec{replicas: 3}} == Object{spec: Object.spec{replicas: 1 + 2}}",
|
||||||
|
expectedValue: true,
|
||||||
|
},
|
||||||
} {
|
} {
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
_, option := mutation.NewTypeProviderAndEnvOption(&TypeResolver{})
|
_, option := mutation.NewTypeProviderAndEnvOption(&TypeResolver{})
|
||||||
|
Loading…
Reference in New Issue
Block a user