Skip to content

Commit 88c0ee1

Browse files
committed
chore: add test for copy perms
1 parent 6c66d06 commit 88c0ee1

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

internal/provider/cached_image_resource_test.go

+35
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,41 @@ RUN date > /date.txt`,
161161
)
162162
},
163163
},
164+
{
165+
// This tests correct handling of the difference in permissions between
166+
// the provider and the image when running a COPY instruction.
167+
name: "copy_perms",
168+
files: map[string]string{
169+
"Dockerfile": `
170+
FROM localhost:5000/test-ubuntu:latest
171+
COPY date.txt /date.txt`,
172+
"date.txt": fmt.Sprintf("%d", time.Now().Unix()),
173+
},
174+
extraEnv: map[string]string{
175+
"CODER_AGENT_TOKEN": "some-token",
176+
"CODER_AGENT_URL": "https://coder.example.com",
177+
"FOO": testEnvValue,
178+
"ENVBUILDER_GIT_URL": "https://not.the.real.git/url",
179+
"ENVBUILDER_CACHE_REPO": "not-the-real-cache-repo",
180+
"ENVBUILDER_DOCKERFILE_PATH": "Dockerfile",
181+
},
182+
assertEnv: func(t *testing.T, deps testDependencies) resource.TestCheckFunc {
183+
return resource.ComposeAggregateTestCheckFunc(
184+
assertEnv(t,
185+
"CODER_AGENT_TOKEN", "some-token",
186+
"CODER_AGENT_URL", "https://coder.example.com",
187+
"ENVBUILDER_CACHE_REPO", deps.CacheRepo,
188+
"ENVBUILDER_DOCKERFILE_PATH", "Dockerfile",
189+
"ENVBUILDER_DOCKER_CONFIG_BASE64", deps.DockerConfigBase64,
190+
"ENVBUILDER_GIT_SSH_PRIVATE_KEY_PATH", deps.Repo.Key,
191+
"ENVBUILDER_GIT_URL", deps.Repo.URL,
192+
"ENVBUILDER_REMOTE_REPO_BUILD_MODE", "true",
193+
"ENVBUILDER_VERBOSE", "true",
194+
"FOO", "bar\nbaz",
195+
),
196+
)
197+
},
198+
},
164199
} {
165200
t.Run(tc.name, func(t *testing.T) {
166201
//nolint: paralleltest

0 commit comments

Comments
 (0)