diff --git a/pkg/e2e/compose_environment_test.go b/pkg/e2e/compose_environment_test.go index 3314617c787..38673928cc3 100644 --- a/pkg/e2e/compose_environment_test.go +++ b/pkg/e2e/compose_environment_test.go @@ -78,6 +78,19 @@ func TestEnvPriority(t *testing.T) { assert.Equal(t, strings.TrimSpace(res.Stdout()), "shell-run") }) + // No Compose file & no env variable but override env file + // 1. Compose file + // 2. Shell environment variables + // 3. Environment file <-- Result expected + // 4. Dockerfile + // 5. Variable is not defined + t.Run("override env file from compose", func(t *testing.T) { + res := c.RunDockerComposeCmd("-f", "./fixtures/environment/env-priority/compose-with-env-file.yaml", + "--project-directory", projectDir, + "run", "--rm", "-e", "WHEREAMI", "env-compose-priority") + assert.Equal(t, strings.TrimSpace(res.Stdout()), "override") + }) + // No Compose file & no env variable but override env file // 1. Compose file // 2. Shell environment variables diff --git a/pkg/e2e/fixtures/environment/env-priority/compose-with-env-file.yaml b/pkg/e2e/fixtures/environment/env-priority/compose-with-env-file.yaml new file mode 100644 index 00000000000..4659830f2e6 --- /dev/null +++ b/pkg/e2e/fixtures/environment/env-priority/compose-with-env-file.yaml @@ -0,0 +1,7 @@ +services: + env-compose-priority: + image: env-compose-priority + build: + context: . + env_file: + - .env.override