(t *testing.T)
| 870 | } |
| 871 | |
| 872 | func TestExpandFile(t *testing.T) { |
| 873 | cfg := []byte(` |
| 874 | kind: source |
| 875 | spec: |
| 876 | name: test |
| 877 | version: v1.0.0 |
| 878 | spec: |
| 879 | credentials: ${file:./testdata/creds.txt} |
| 880 | otherstuff: 2 |
| 881 | credentials1: [${file:./testdata/creds.txt}, ${file:./testdata/creds1.txt}] |
| 882 | `) |
| 883 | expectedCfg := []byte(` |
| 884 | kind: source |
| 885 | spec: |
| 886 | name: test |
| 887 | version: v1.0.0 |
| 888 | spec: |
| 889 | credentials: mytestcreds |
| 890 | otherstuff: 2 |
| 891 | credentials1: [mytestcreds, anothercredtest] |
| 892 | `) |
| 893 | expandedCfg, err := expandFileConfig(cfg) |
| 894 | if err != nil { |
| 895 | t.Fatal(err) |
| 896 | } |
| 897 | if !bytes.Equal(expandedCfg, expectedCfg) { |
| 898 | t.Fatalf("got: %s expected: %s", expandedCfg, expectedCfg) |
| 899 | } |
| 900 | |
| 901 | badCfg := []byte(` |
| 902 | kind: source |
| 903 | spec: |
| 904 | name: test |
| 905 | version: v1.0.0 |
| 906 | spec: |
| 907 | credentials: ${file:./testdata/creds2.txt} |
| 908 | otherstuff: 2 |
| 909 | `) |
| 910 | _, err = expandFileConfig(badCfg) |
| 911 | if !os.IsNotExist(err) { |
| 912 | t.Fatalf("expected error: %s, got: %s", os.ErrNotExist, err) |
| 913 | } |
| 914 | } |
| 915 | |
| 916 | func TestExpandEnv(t *testing.T) { |
| 917 | os.Setenv("TEST_ENV_CREDS", "mytestcreds") |
nothing calls this directly
no test coverage detected