File tree Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -808,6 +808,24 @@ func TestExpr(t *testing.T) {
808808 }
809809}
810810
811+ func TestExpr_eval_with_env (t * testing.T ) {
812+ _ , err := expr .Eval ("true" , expr .Env (map [string ]interface {}{}))
813+ assert .Error (t , err )
814+ assert .Contains (t , err .Error (), "misused" )
815+ }
816+
817+ func TestExpr_fetch_from_func (t * testing.T ) {
818+ _ , err := expr .Eval ("foo.Value" , map [string ]interface {}{
819+ "foo" : func () {},
820+ })
821+ assert .Error (t , err )
822+ assert .Contains (t , err .Error (), "cannot fetch Value from func()" )
823+ }
824+
825+ //
826+ // Mock types
827+ //
828+
811829type mockEnv struct {
812830 Any interface {}
813831 Int , One , Two , Three int
@@ -903,9 +921,3 @@ type segment struct {
903921 Destination string
904922 Date time.Time
905923}
906-
907- func TestExpr_eval_with_env (t * testing.T ) {
908- _ , err := expr .Eval ("true" , expr .Env (map [string ]interface {}{}))
909- assert .Error (t , err )
910- assert .Contains (t , err .Error (), "misused" )
911- }
Original file line number Diff line number Diff line change @@ -46,6 +46,9 @@ func fetch(from interface{}, i interface{}) interface{} {
4646 if value .IsValid () && value .CanInterface () {
4747 return value .Interface ()
4848 }
49+
50+ case reflect .Func :
51+ panic (fmt .Sprintf ("cannot fetch %v from %T" , i , from ))
4952 }
5053 return nil
5154}
You can’t perform that action at this time.
0 commit comments