(t *testing.T)
| 634 | } |
| 635 | |
| 636 | func TestEnvironmentReplacement(t *testing.T) { |
| 637 | os.Setenv("FOOBAR", "foobar") |
| 638 | os.Setenv("CHAINED", "$FOOBAR") |
| 639 | |
| 640 | for i, test := range []struct { |
| 641 | input string |
| 642 | expect string |
| 643 | }{ |
| 644 | { |
| 645 | input: "", |
| 646 | expect: "", |
| 647 | }, |
| 648 | { |
| 649 | input: "foo", |
| 650 | expect: "foo", |
| 651 | }, |
| 652 | { |
| 653 | input: "{$NOT_SET}", |
| 654 | expect: "", |
| 655 | }, |
| 656 | { |
| 657 | input: "foo{$NOT_SET}bar", |
| 658 | expect: "foobar", |
| 659 | }, |
| 660 | { |
| 661 | input: "{$FOOBAR}", |
| 662 | expect: "foobar", |
| 663 | }, |
| 664 | { |
| 665 | input: "foo {$FOOBAR} bar", |
| 666 | expect: "foo foobar bar", |
| 667 | }, |
| 668 | { |
| 669 | input: "foo{$FOOBAR}bar", |
| 670 | expect: "foofoobarbar", |
| 671 | }, |
| 672 | { |
| 673 | input: "foo\n{$FOOBAR}\nbar", |
| 674 | expect: "foo\nfoobar\nbar", |
| 675 | }, |
| 676 | { |
| 677 | input: "{$FOOBAR} {$FOOBAR}", |
| 678 | expect: "foobar foobar", |
| 679 | }, |
| 680 | { |
| 681 | input: "{$FOOBAR}{$FOOBAR}", |
| 682 | expect: "foobarfoobar", |
| 683 | }, |
| 684 | { |
| 685 | input: "{$CHAINED}", |
| 686 | expect: "$FOOBAR", // should not chain env expands |
| 687 | }, |
| 688 | { |
| 689 | input: "{$FOO:default}", |
| 690 | expect: "default", |
| 691 | }, |
| 692 | { |
| 693 | input: "foo{$BAR:bar}baz", |
nothing calls this directly
no test coverage detected