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

Function TestUnparseErrors

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

Source from the content-addressed store, hash-verified

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