(t *testing.T)
| 609 | } |
| 610 | |
| 611 | func TestEnvFromConfig(t *testing.T) { |
| 612 | type exprCase struct { |
| 613 | name string |
| 614 | in any |
| 615 | expr string |
| 616 | iss error |
| 617 | out ref.Val |
| 618 | } |
| 619 | tests := []struct { |
| 620 | name string |
| 621 | beforeOpts []EnvOption |
| 622 | afterOpts []EnvOption |
| 623 | conf *env.Config |
| 624 | confHandlers []ConfigOptionFactory |
| 625 | exprs []exprCase |
| 626 | }{ |
| 627 | { |
| 628 | name: "std env", |
| 629 | conf: env.NewConfig("std env"), |
| 630 | exprs: []exprCase{ |
| 631 | { |
| 632 | name: "literal", |
| 633 | expr: "'hello world'", |
| 634 | out: types.String("hello world"), |
| 635 | }, |
| 636 | { |
| 637 | name: "size", |
| 638 | expr: "'hello world'.size()", |
| 639 | out: types.Int(11), |
| 640 | }, |
| 641 | }, |
| 642 | }, |
| 643 | { |
| 644 | name: "std env - imports", |
| 645 | beforeOpts: []EnvOption{Types(&proto3pb.TestAllTypes{})}, |
| 646 | conf: env.NewConfig("std env - imports"). |
| 647 | AddImports(env.NewImport("google.expr.proto3.test.TestAllTypes")), |
| 648 | exprs: []exprCase{ |
| 649 | { |
| 650 | name: "literal", |
| 651 | expr: "TestAllTypes{single_int64: 15}.single_int64", |
| 652 | out: types.Int(15), |
| 653 | }, |
| 654 | }, |
| 655 | }, |
| 656 | { |
| 657 | name: "std env - context proto", |
| 658 | beforeOpts: []EnvOption{Types(&proto3pb.TestAllTypes{})}, |
| 659 | conf: env.NewConfig("std env - context proto"). |
| 660 | SetContainer("google.expr.proto3.test"). |
| 661 | SetContextVariable(env.NewContextVariable("google.expr.proto3.test.TestAllTypes")), |
| 662 | exprs: []exprCase{ |
| 663 | { |
| 664 | name: "field select literal", |
| 665 | in: mustContextProto(t, &proto3pb.TestAllTypes{SingleInt64: 10}), |
| 666 | expr: "TestAllTypes{single_int64: single_int64}.single_int64", |
| 667 | out: types.Int(10), |
| 668 | }, |
nothing calls this directly
no test coverage detected