From 3f111e909cd3a806536f08fc88b80f2066171328 Mon Sep 17 00:00:00 2001 From: Danis Kirasirov <dbgbbu@gmail.com> Date: Fri, 2 Feb 2024 10:24:59 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D1=8B=20=D1=82=D0=B5=D1=81=D1=82=D1=8B=20=D0=B4=D0=BB?= =?UTF-8?q?=D1=8F=20=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=BE=D0=B2=20=D1=81?= =?UTF-8?q?=D1=82=D1=80=D1=83=D0=BA=D1=82=D1=83=D1=80=20=D0=B2=20expr?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/expr/expr_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/pkg/expr/expr_test.go b/pkg/expr/expr_test.go index 8fb68311..14bab92f 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", -- GitLab