(t *testing.T)
| 607 | } |
| 608 | |
| 609 | func TestVariableAsCELVariable(t *testing.T) { |
| 610 | tests := []struct { |
| 611 | name string |
| 612 | v *Variable |
| 613 | want any |
| 614 | }{ |
| 615 | { |
| 616 | name: "nil-safety check", |
| 617 | v: nil, |
| 618 | want: errors.New("invalid variable: nil"), |
| 619 | }, |
| 620 | { |
| 621 | name: "no variable name", |
| 622 | v: &Variable{}, |
| 623 | want: errors.New("invalid variable"), |
| 624 | }, |
| 625 | { |
| 626 | name: "no type", |
| 627 | v: &Variable{ |
| 628 | Name: "hello", |
| 629 | }, |
| 630 | want: errors.New("invalid type: nil"), |
| 631 | }, |
| 632 | { |
| 633 | name: "bad type", |
| 634 | v: &Variable{ |
| 635 | Name: "hello", |
| 636 | TypeDesc: &TypeDesc{}, |
| 637 | }, |
| 638 | want: errors.New("missing type name"), |
| 639 | }, |
| 640 | { |
| 641 | name: "undefined type", |
| 642 | v: &Variable{ |
| 643 | Name: "hello", |
| 644 | TypeDesc: &TypeDesc{TypeName: "undefined"}, |
| 645 | }, |
| 646 | want: errors.New("undefined type name"), |
| 647 | }, |
| 648 | { |
| 649 | name: "simple type", |
| 650 | v: &Variable{ |
| 651 | Name: "t", |
| 652 | TypeDesc: &TypeDesc{TypeName: "type"}, |
| 653 | }, |
| 654 | want: decls.NewVariable("t", types.TypeType), |
| 655 | }, |
| 656 | { |
| 657 | name: "type with param", |
| 658 | v: &Variable{ |
| 659 | Name: "t", |
| 660 | TypeDesc: &TypeDesc{TypeName: "type", Params: []*TypeDesc{NewTypeParam("T")}}, |
| 661 | }, |
| 662 | want: decls.NewVariable("t", types.NewTypeTypeWithParam(types.NewTypeParamType("T"))), |
| 663 | }, |
| 664 | { |
| 665 | name: "type with too many params", |
| 666 | v: &Variable{ |
nothing calls this directly
no test coverage detected