Skip to content

Commit ccd8731

Browse files
committed
e2e: always set HOME + USER for cmd env
Signed-off-by: Milas Bowman <[email protected]>
1 parent 3ae6c52 commit ccd8731

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

pkg/e2e/ddev_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,6 @@ func TestComposeRunDdev(t *testing.T) {
5656

5757
c := NewCLI(t, WithEnv(
5858
"DDEV_DEBUG=true",
59-
fmt.Sprintf("HOME=%s", t.TempDir()),
60-
fmt.Sprintf("USER=%s", os.Getenv("USER")),
6159
fmt.Sprintf("PATH=%s", pathDir),
6260
))
6361

pkg/e2e/framework.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,15 @@ func init() {
5959

6060
// CLI is used to wrap the CLI for end to end testing
6161
type CLI struct {
62+
// ConfigDir for Docker configuration (set as DOCKER_CONFIG)
6263
ConfigDir string
6364

65+
// HomeDir for tools that look for user files (set as HOME)
66+
HomeDir string
67+
68+
// env overrides to apply to every invoked command
69+
//
70+
// To populate, use WithEnv when creating a CLI instance.
6471
env []string
6572
}
6673

@@ -84,6 +91,7 @@ func NewCLI(t testing.TB, opts ...CLIOption) *CLI {
8491

8592
c := &CLI{
8693
ConfigDir: configDir,
94+
HomeDir: t.TempDir(),
8795
}
8896

8997
for _, opt := range opts {
@@ -188,6 +196,8 @@ func CopyFile(sourceFile string, destinationFile string) error {
188196
// Docker / Compose commands.
189197
func (c *CLI) BaseEnvironment() []string {
190198
return []string{
199+
"HOME=" + c.HomeDir,
200+
"USER=" + os.Getenv("USER"),
191201
"DOCKER_CONFIG=" + c.ConfigDir,
192202
"KUBECONFIG=invalid",
193203
}

0 commit comments

Comments
 (0)