diff --git a/pkg/expr/expr_test.go b/pkg/expr/expr_test.go index 8fb6831110137b1e4d2d897edd37628c20b35f5c..14bab92fb4fdf2c4d1a890e918a4809615c83c2f 100644 --- a/pkg/expr/expr_test.go +++ b/pkg/expr/expr_test.go @@ -58,6 +58,10 @@ type testEnvStruct struct { Data interface{} `expr:"data"` } +func (s *testEnvStruct) Equal(other *testEnvStruct) bool { + return s.ID == other.ID +} + func TestEval_StructInEnv(t *testing.T) { ctx := context.Background() @@ -92,6 +96,12 @@ func TestEval_StructInEnv(t *testing.T) { env: map[string]interface{}{"s": &testEnvStruct{Data: &testEnvStruct{Size: 0}}}, wantResult: true, }, + { + name: "use method", + exp: "s1.Equal(s2)", + env: map[string]interface{}{"s1": &testEnvStruct{ID: "id1"}, "s2": &testEnvStruct{ID: "id2"}}, + wantResult: false, + }, { name: "field not exists", exp: "s.not_exists",