(t *testing.T)
| 471 | } |
| 472 | |
| 473 | func TestEnvFromConfig(t *testing.T) { |
| 474 | type exprCase struct { |
| 475 | name string |
| 476 | in any |
| 477 | expr string |
| 478 | iss error |
| 479 | out ref.Val |
| 480 | } |
| 481 | tests := []struct { |
| 482 | name string |
| 483 | beforeOpts []EnvOption |
| 484 | afterOpts []EnvOption |
| 485 | conf *env.Config |
| 486 | confHandlers []ConfigOptionFactory |
| 487 | exprs []exprCase |
| 488 | }{ |
| 489 | { |
| 490 | name: "std env", |
| 491 | conf: env.NewConfig("std env"), |
| 492 | exprs: []exprCase{ |
| 493 | { |
| 494 | name: "literal", |
| 495 | expr: "'hello world'", |
| 496 | out: types.String("hello world"), |
| 497 | }, |
| 498 | { |
| 499 | name: "size", |
| 500 | expr: "'hello world'.size()", |
| 501 | out: types.Int(11), |
| 502 | }, |
| 503 | }, |
| 504 | }, |
| 505 | { |
| 506 | name: "std env - imports", |
| 507 | beforeOpts: []EnvOption{Types(&proto3pb.TestAllTypes{})}, |
| 508 | conf: env.NewConfig("std env - imports"). |
| 509 | AddImports(env.NewImport("google.expr.proto3.test.TestAllTypes")), |
| 510 | exprs: []exprCase{ |
| 511 | { |
| 512 | name: "literal", |
| 513 | expr: "TestAllTypes{single_int64: 15}.single_int64", |
| 514 | out: types.Int(15), |
| 515 | }, |
| 516 | }, |
| 517 | }, |
| 518 | { |
| 519 | name: "std env - context proto", |
| 520 | beforeOpts: []EnvOption{Types(&proto3pb.TestAllTypes{})}, |
| 521 | conf: env.NewConfig("std env - context proto"). |
| 522 | SetContainer("google.expr.proto3.test"). |
| 523 | SetContextVariable(env.NewContextVariable("google.expr.proto3.test.TestAllTypes")), |
| 524 | exprs: []exprCase{ |
| 525 | { |
| 526 | name: "field select literal", |
| 527 | in: mustContextProto(t, &proto3pb.TestAllTypes{SingleInt64: 10}), |
| 528 | expr: "TestAllTypes{single_int64: single_int64}.single_int64", |
| 529 | out: types.Int(10), |
| 530 | }, |
nothing calls this directly
no test coverage detected