Skip to content

Commit a2303ae

Browse files
committed
fix unit tests
1 parent 6e4a087 commit a2303ae

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

evaluation/reflection_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ func Test_caseInsensitiveFieldByName(t *testing.T) {
8484
for _, tt := range tests {
8585
val := tt
8686
t.Run(val.name, func(t *testing.T) {
87-
if got := caseInsensitiveFieldByName(val.args.v, val.args.name); got == val.want {
87+
if got := caseInsensitiveFieldByName(val.args.v, val.args.name); !reflect.DeepEqual(got.Interface(),
88+
val.want.Interface()) {
8889
t.Errorf("caseInsensitiveFieldByName() = %v, want %v", got, val.want)
8990
}
9091
})

evaluation/target_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ func TestTarget_GetOperator(t1 *testing.T) {
7575

7676
func TestTarget_GetAttrValue(t1 *testing.T) {
7777
name := "John"
78+
identifier := "john"
79+
email := "[email protected]"
7880
type fields struct {
7981
Identifier string
8082
Name *string
@@ -95,17 +97,17 @@ func TestTarget_GetAttrValue(t1 *testing.T) {
9597
Name *string
9698
Anonymous bool
9799
Attributes map[string]interface{}
98-
}{Identifier: "john", Name: &name, Anonymous: false, Attributes: types.JSON{}},
99-
args: struct{ attr string }{attr: "identifier"}, want: reflect.ValueOf("john")},
100+
}{Identifier: identifier, Name: &name, Anonymous: false, Attributes: types.JSON{}},
101+
args: struct{ attr string }{attr: "identifier"}, want: reflect.ValueOf(identifier)},
100102
{name: "check attributes", fields: struct {
101103
Identifier string
102104
Name *string
103105
Anonymous bool
104106
Attributes map[string]interface{}
105107
}{Identifier: "john", Name: &name, Anonymous: false, Attributes: types.JSON{
106-
"email": "[email protected]",
108+
"email": email,
107109
}},
108-
args: struct{ attr string }{attr: "email"}, want: reflect.ValueOf("[email protected]")},
110+
args: struct{ attr string }{attr: "email"}, want: reflect.ValueOf(email)},
109111
}
110112
for _, tt := range tests {
111113
val := tt
@@ -116,7 +118,7 @@ func TestTarget_GetAttrValue(t1 *testing.T) {
116118
Anonymous: val.fields.Anonymous,
117119
Attributes: val.fields.Attributes,
118120
}
119-
if got := t.GetAttrValue(val.args.attr); got == val.want {
121+
if got := t.GetAttrValue(val.args.attr); !reflect.DeepEqual(got.Interface(), val.want.Interface()) {
120122
t1.Errorf("GetAttrValue() = %v, want %v", got, val.want)
121123
}
122124
})

0 commit comments

Comments
 (0)