MCPcopy Create free account
hub / github.com/coder/envbuilder / TestChownHomedir

Function TestChownHomedir

integration/integration_test.go:2556–2588  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2554}
2555
2556func TestChownHomedir(t *testing.T) {
2557 t.Parallel()
2558
2559 // Ensures that a Git repository with a devcontainer.json is cloned and built.
2560 srv := gittest.CreateGitServer(t, gittest.Options{
2561 Files: map[string]string{
2562 ".devcontainer/devcontainer.json": `{
2563 "name": "Test",
2564 "build": {
2565 "dockerfile": "Dockerfile"
2566 },
2567 }`,
2568 ".devcontainer/Dockerfile": fmt.Sprintf(`FROM %s
2569RUN useradd test \
2570 --create-home \
2571 --shell=/bin/bash \
2572 --uid=1001 \
2573 --user-group
2574USER test
2575`, testImageUbuntu), // Note: this isn't reproducible with Alpine for some reason.
2576 },
2577 })
2578
2579 // Run envbuilder with a Docker volume mounted to homedir
2580 volName := fmt.Sprintf("%s%d-home", t.Name(), time.Now().Unix())
2581 ctr, err := runEnvbuilder(t, runOpts{env: []string{
2582 envbuilderEnv("GIT_URL", srv.URL),
2583 }, volumes: map[string]string{volName: "/home/test"}})
2584 require.NoError(t, err)
2585
2586 output := execContainer(t, ctr, "stat -c %u:%g /home/test/")
2587 require.Equal(t, "1001:1001", strings.TrimSpace(output))
2588}
2589
2590type setupInMemoryRegistryOpts struct {
2591 Username string

Callers

nothing calls this directly

Calls 5

CreateGitServerFunction · 0.92
runEnvbuilderFunction · 0.85
envbuilderEnvFunction · 0.85
execContainerFunction · 0.85
NameMethod · 0.45

Tested by

no test coverage detected