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

Function TestConvertProtoToEntryExpr

common/ast/conversion_test.go:284–366  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

282}
283
284func TestConvertProtoToEntryExpr(t *testing.T) {
285 fac := ast.NewExprFactory()
286 tests := []struct {
287 goAST ast.EntryExpr
288 pbAST *exprpb.Expr_CreateStruct_Entry
289 }{
290 {
291 goAST: fac.NewMapEntry(1,
292 fac.NewIdent(2, "var_key"),
293 fac.NewLiteral(3, types.String("hello")),
294 true),
295 pbAST: &exprpb.Expr_CreateStruct_Entry{
296 Id: 1,
297 KeyKind: &exprpb.Expr_CreateStruct_Entry_MapKey{
298 MapKey: &exprpb.Expr{
299 Id: 2,
300 ExprKind: &exprpb.Expr_IdentExpr{
301 IdentExpr: &exprpb.Expr_Ident{
302 Name: "var_key",
303 },
304 },
305 },
306 },
307 Value: &exprpb.Expr{
308 Id: 3,
309 ExprKind: &exprpb.Expr_ConstExpr{
310 ConstExpr: &exprpb.Constant{
311 ConstantKind: &exprpb.Constant_StringValue{
312 StringValue: "hello",
313 },
314 },
315 },
316 },
317 OptionalEntry: true,
318 },
319 },
320 {
321 goAST: fac.NewStructField(1,
322 "field_name",
323 fac.NewLiteral(2, types.String("hello")),
324 false),
325 pbAST: &exprpb.Expr_CreateStruct_Entry{
326 Id: 1,
327 KeyKind: &exprpb.Expr_CreateStruct_Entry_FieldKey{
328 FieldKey: "field_name",
329 },
330 Value: &exprpb.Expr{
331 Id: 2,
332 ExprKind: &exprpb.Expr_ConstExpr{
333 ConstExpr: &exprpb.Constant{
334 ConstantKind: &exprpb.Constant_StringValue{
335 StringValue: "hello",
336 },
337 },
338 },
339 },
340 OptionalEntry: false,
341 },

Callers

nothing calls this directly

Calls 9

NewMapEntryMethod · 0.95
NewIdentMethod · 0.95
NewLiteralMethod · 0.95
NewStructFieldMethod · 0.95
NewExprFactoryFunction · 0.92
StringTypeAlias · 0.92
ProtoToEntryExprFunction · 0.92
EntryExprToProtoFunction · 0.92
EqualMethod · 0.65

Tested by

no test coverage detected