Skip to content

Commit 2c14f1c

Browse files
committed
load: fix windows tests
Various places were using absolute Unix paths, which don't work on Windows. Signed-off-by: Milas Bowman <[email protected]>
1 parent ba2b641 commit 2c14f1c

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

loader/full-example.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ services:
2424
- bar
2525
labels: [FOO=BAR]
2626
additional_contexts:
27-
foo: /bar
27+
foo: ./bar
2828
secrets:
2929
- secret1
3030
- source: secret2

loader/full-struct_test.go

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func services(workingDir, homeDir string) []types.ServiceConfig {
6060
Target: "foo",
6161
Network: "foo",
6262
CacheFrom: []string{"foo", "bar"},
63-
AdditionalContexts: types.Mapping{"foo": "/bar"},
63+
AdditionalContexts: types.Mapping{"foo": filepath.Join(workingDir, "bar")},
6464
Labels: map[string]string{"FOO": "BAR"},
6565
Secrets: []types.ServiceSecretConfig{
6666
{
@@ -619,7 +619,7 @@ services:
619619
- foo
620620
- bar
621621
additional_contexts:
622-
foo: /bar
622+
foo: %s
623623
network: foo
624624
target: foo
625625
secrets:
@@ -1041,6 +1041,7 @@ x-nested:
10411041
`,
10421042
workingDir,
10431043
filepath.Join(workingDir, "dir"),
1044+
filepath.Join(workingDir, "bar"),
10441045
filepath.Join(workingDir, "example1.env"),
10451046
filepath.Join(workingDir, "example2.env"),
10461047
workingDir,
@@ -1152,7 +1153,7 @@ func fullExampleJSON(workingDir, homeDir string) string {
11521153
"services": {
11531154
"bar": {
11541155
"build": {
1155-
"context": %q,
1156+
"context": "%s",
11561157
"dockerfile_inline": "FROM alpine\nRUN echo \"hello\" \u003e /world.txt\n"
11571158
},
11581159
"command": null,
@@ -1163,7 +1164,7 @@ func fullExampleJSON(workingDir, homeDir string) string {
11631164
"com.example.foo": "bar"
11641165
},
11651166
"build": {
1166-
"context": %q,
1167+
"context": "%s",
11671168
"dockerfile": "Dockerfile",
11681169
"args": {
11691170
"foo": "bar"
@@ -1179,7 +1180,7 @@ func fullExampleJSON(workingDir, homeDir string) string {
11791180
"bar"
11801181
],
11811182
"additional_contexts": {
1182-
"foo": "/bar"
1183+
"foo": "%s"
11831184
},
11841185
"network": "foo",
11851186
"target": "foo",
@@ -1690,6 +1691,7 @@ func fullExampleJSON(workingDir, homeDir string) string {
16901691
toPath(workingDir, "secret_data"),
16911692
toPath(workingDir),
16921693
toPath(workingDir, "dir"),
1694+
toPath(workingDir, "bar"),
16931695
toPath(workingDir, "example1.env"),
16941696
toPath(workingDir, "example2.env"),
16951697
toPath(workingDir),

loader/paths_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ func TestResolveBuildContextPaths(t *testing.T) {
8484

8585
func TestResolveAdditionalContexts(t *testing.T) {
8686
wd, _ := filepath.Abs(".")
87+
absSubdir := filepath.Join(wd, "dir")
8788
project := types.Project{
8889
Name: "myProject",
8990
WorkingDir: wd,
@@ -96,7 +97,7 @@ func TestResolveAdditionalContexts(t *testing.T) {
9697
AdditionalContexts: map[string]string{
9798
"image": "docker-image://foo",
9899
"oci": "oci-layout://foo",
99-
"abs_path": "/tmp",
100+
"abs_path": absSubdir,
100101
"github": "github.com/compose-spec/compose-go",
101102
"rel_path": "./testdata",
102103
},
@@ -117,7 +118,7 @@ func TestResolveAdditionalContexts(t *testing.T) {
117118
AdditionalContexts: map[string]string{
118119
"image": "docker-image://foo",
119120
"oci": "oci-layout://foo",
120-
"abs_path": "/tmp",
121+
"abs_path": absSubdir,
121122
"github": "github.com/compose-spec/compose-go",
122123
"rel_path": filepath.Join(wd, "testdata"),
123124
},

0 commit comments

Comments
 (0)