(t *testing.T)
| 789 | } |
| 790 | |
| 791 | func TestDiscardEnvFileOption(t *testing.T) { |
| 792 | dict, err := ParseYAML([]byte(`version: "3" |
| 793 | services: |
| 794 | web: |
| 795 | image: nginx |
| 796 | env_file: |
| 797 | - example1.env |
| 798 | - example2.env |
| 799 | `)) |
| 800 | expectedEnvironmentMap := types.MappingWithEquals{ |
| 801 | "FOO": strPtr("foo_from_env_file"), |
| 802 | "BAZ": strPtr("baz_from_env_file"), |
| 803 | "BAR": strPtr("bar_from_env_file_2"), // Original value is overwritten by example2.env |
| 804 | "QUX": strPtr("quz_from_env_file_2"), |
| 805 | } |
| 806 | assert.NilError(t, err) |
| 807 | configDetails := buildConfigDetails(dict, nil) |
| 808 | |
| 809 | // Default behavior keeps the `env_file` entries |
| 810 | configWithEnvFiles, err := Load(configDetails) |
| 811 | assert.NilError(t, err) |
| 812 | expected := types.StringList{"example1.env", "example2.env"} |
| 813 | assert.Check(t, is.DeepEqual(expected, configWithEnvFiles.Services[0].EnvFile)) |
| 814 | assert.Check(t, is.DeepEqual(expectedEnvironmentMap, configWithEnvFiles.Services[0].Environment)) |
| 815 | |
| 816 | // Custom behavior removes the `env_file` entries |
| 817 | configWithoutEnvFiles, err := Load(configDetails, WithDiscardEnvFiles) |
| 818 | assert.NilError(t, err) |
| 819 | expected = types.StringList(nil) |
| 820 | assert.Check(t, is.DeepEqual(expected, configWithoutEnvFiles.Services[0].EnvFile)) |
| 821 | assert.Check(t, is.DeepEqual(expectedEnvironmentMap, configWithoutEnvFiles.Services[0].Environment)) |
| 822 | } |
| 823 | |
| 824 | func TestBuildProperties(t *testing.T) { |
| 825 | dict, err := ParseYAML([]byte(` |
nothing calls this directly
no test coverage detected
searching dependent graphs…