Skip to content

Commit 8f4f29f

Browse files
committed
test interpolation with extends
Signed-off-by: Nicolas De Loof <[email protected]>
1 parent 96ce1d2 commit 8f4f29f

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FOO=FOO-from-extends
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
services:
2+
test:
3+
extends:
4+
service: test
5+
file: ../compose.yaml
6+
environment:
7+
- BAR=BAR-from-extends
8+
9+
example:
10+
extends:
11+
service: example
12+
file: ../compose.yaml

pkg/e2e/interpolation_test.go

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ func Test_interpolation(t *testing.T) {
4343
env := getEnv(res.Combined())
4444

4545
assert.Check(t, slices.Contains(env, "FOO=FOO-from-dot-env"))
46+
assert.Check(t, slices.Contains(env, "BAR=bar_from_environment"))
4647
assert.Check(t, slices.Contains(env, "ZOT=FOO-from-dot-env"))
4748
assert.Check(t, slices.Contains(env, "QIX=some FOO-from-dot-env value"))
4849
assert.Check(t, slices.Contains(env, "BAR_FROM_ENV_FILE=bar_from_environment"))
@@ -66,13 +67,37 @@ func Test_interpolationWithInclude(t *testing.T) {
6667
env := getEnv(res.Combined())
6768

6869
assert.Check(t, slices.Contains(env, "FOO=FOO-from-include"))
70+
assert.Check(t, slices.Contains(env, "BAR=bar_from_environment"))
6971
assert.Check(t, slices.Contains(env, "ZOT=FOO-from-include"))
7072
assert.Check(t, slices.Contains(env, "QIX=some FOO-from-include value"))
7173

7274
assert.Check(t, slices.Contains(env, "BY_PROVIDER_FROM_ENV=https://magic.cloud/example"))
7375
assert.Check(t, slices.Contains(env, "BY_PROVIDER_FROM_ENV_FILE=https://magic.cloud/example"))
7476
}
7577

78+
func Test_interpolationWithExtends(t *testing.T) {
79+
provider, err := findExecutable("example-provider")
80+
assert.NilError(t, err)
81+
path := fmt.Sprintf("%s%s%s", os.Getenv("PATH"), string(os.PathListSeparator), filepath.Dir(provider))
82+
c := NewParallelCLI(t, WithEnv("PATH="+path))
83+
84+
const projectName = "interpolation-extends"
85+
t.Cleanup(func() {
86+
c.cleanupWithDown(t, projectName)
87+
})
88+
89+
res := c.RunDockerComposeCmd(t, "-f", "fixtures/interpolation/extends/compose.yaml", "--project-name", projectName, "up")
90+
env := getEnv(res.Combined())
91+
92+
assert.Check(t, slices.Contains(env, "FOO=FOO-from-extends"))
93+
assert.Check(t, slices.Contains(env, "BAR=BAR-from-extends"))
94+
assert.Check(t, slices.Contains(env, "ZOT=FOO-from-extends"))
95+
assert.Check(t, slices.Contains(env, "QIX=some FOO-from-extends value"))
96+
97+
assert.Check(t, slices.Contains(env, "BY_PROVIDER_FROM_ENV=https://magic.cloud/example"))
98+
assert.Check(t, slices.Contains(env, "BY_PROVIDER_FROM_ENV_FILE=https://magic.cloud/example"))
99+
}
100+
76101
func getEnv(out string) []string {
77102
var env []string
78103
scanner := bufio.NewScanner(strings.NewReader(out))

0 commit comments

Comments
 (0)