(t *testing.T)
| 2554 | } |
| 2555 | |
| 2556 | func 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 |
| 2569 | RUN useradd test \ |
| 2570 | --create-home \ |
| 2571 | --shell=/bin/bash \ |
| 2572 | --uid=1001 \ |
| 2573 | --user-group |
| 2574 | USER 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 | |
| 2590 | type setupInMemoryRegistryOpts struct { |
| 2591 | Username string |
nothing calls this directly
no test coverage detected