MCPcopy Create free account
hub / github.com/cel-expr/cel-go / TestUnparseErrors

Function TestUnparseErrors

parser/unparser_test.go:519–636  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

517}
518
519func TestUnparseErrors(t *testing.T) {
520 validConstantExpression := &exprpb.Expr{
521 ExprKind: &exprpb.Expr_ConstExpr{
522 ConstExpr: &exprpb.Constant{
523 ConstantKind: &exprpb.Constant_NullValue{},
524 },
525 },
526 }
527 tests := []struct {
528 name string
529 in *exprpb.Expr
530 err error
531 unparserOptions []UnparserOption
532 }{
533 {name: "empty_expr", in: &exprpb.Expr{}, err: errors.New("unsupported expression")},
534 {
535 name: "bad_args",
536 in: &exprpb.Expr{
537 ExprKind: &exprpb.Expr_CallExpr{
538 CallExpr: &exprpb.Expr_Call{
539 Function: "_&&_",
540 Args: []*exprpb.Expr{{}, {}},
541 },
542 },
543 },
544 err: errors.New("unsupported expression"),
545 },
546 {
547 name: "bad_struct",
548 in: &exprpb.Expr{
549 ExprKind: &exprpb.Expr_StructExpr{
550 StructExpr: &exprpb.Expr_CreateStruct{
551 MessageName: "Msg",
552 Entries: []*exprpb.Expr_CreateStruct_Entry{
553 {KeyKind: &exprpb.Expr_CreateStruct_Entry_FieldKey{FieldKey: "field"}},
554 },
555 },
556 },
557 },
558 err: errors.New("unsupported expression"),
559 },
560 {
561 name: "bad_map",
562 in: &exprpb.Expr{
563 ExprKind: &exprpb.Expr_StructExpr{
564 StructExpr: &exprpb.Expr_CreateStruct{
565 Entries: []*exprpb.Expr_CreateStruct_Entry{
566 {KeyKind: &exprpb.Expr_CreateStruct_Entry_FieldKey{FieldKey: "field"}},
567 },
568 },
569 },
570 },
571 err: errors.New("unsupported expression"),
572 },
573 {
574 name: "bad_index",
575 in: &exprpb.Expr{
576 ExprKind: &exprpb.Expr_CallExpr{

Callers

nothing calls this directly

Calls 8

NewSourceInfoFunction · 0.92
ProtoToExprFunction · 0.92
WrapOnColumnFunction · 0.85
WrapOnOperatorsFunction · 0.85
UnparseFunction · 0.85
NewMethod · 0.80
ContainsMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected