Skip to content
Snippets Groups Projects
Commit 3f111e90 authored by Danis Kirasirov's avatar Danis Kirasirov
Browse files

Добавлены тесты для методов структур в expr

parent 8dbe03c5
No related branches found
No related tags found
No related merge requests found
......@@ -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",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment