Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danepowell authored and stasadev committed Mar 29, 2024
1 parent 1bafa35 commit a95bba1
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cmd/ddev/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,28 +224,29 @@ func TestCreateGlobalDdevDir(t *testing.T) {
// Change the homedir temporarily
t.Setenv("HOME", tmpHomeDir)
t.Setenv("USERPROFILE", tmpHomeDir)
t.Setenv("XDG_CONFIG_HOME", filepath.Join(tmpHomeDir, ".config"))

// Make sure $HOME/.ddev and $XDG_CONFIG_HOME/ddev don't exist before we run ddev.
_, err = os.Stat(filepath.Join(tmpHomeDir, ".ddev"))
require.Error(t, err)
assert.True(os.IsNotExist(err))
_, err = os.Stat(filepath.Join(tmpHomeDir, "Library", "Application Support", "ddev"))
_, err = os.Stat(filepath.Join(tmpHomeDir, ".config", "ddev"))
require.Error(t, err)
assert.True(os.IsNotExist(err))

out, err := exec.RunHostCommand(DdevBin, "config", "--auto")
require.NoError(t, err, "failed to ddev config --auto, out=%v, err=%v", out, err)

// Now $XDG_CONFIG_HOME/ddev should exist
_, err = os.Stat(filepath.Join(tmpHomeDir, "Library", "Application Support", "ddev"))
_, err = os.Stat(filepath.Join(tmpHomeDir, ".config", "ddev"))
require.NoError(t, err)

// Make sure we have the .ddev/bin dir we need for docker-compose and Mutagen
err = fileutil.CopyDir(filepath.Join(origHomeDir, ".ddev/bin"), filepath.Join(tmpHomeDir, "Library", "Application Support", "ddev/bin"))
err = fileutil.CopyDir(filepath.Join(origHomeDir, ".ddev/bin"), filepath.Join(tmpHomeDir, ".config", "ddev/bin"))
require.NoError(t, err)

// Make sure that tmpHomeDir/.ddev/.update don't exist before we run ddev start
tmpUpdateFilePath := filepath.Join(tmpHomeDir, "Library", "Application Support", "ddev", ".update")
tmpUpdateFilePath := filepath.Join(tmpHomeDir, ".config", "ddev", ".update")
_, err = os.Stat(tmpUpdateFilePath)
require.Error(t, err)
assert.True(os.IsNotExist(err))
Expand Down Expand Up @@ -295,20 +296,21 @@ func TestLegacyGlobalDdevDir(t *testing.T) {
// Change the homedir temporarily
t.Setenv("HOME", tmpHomeDir)
t.Setenv("USERPROFILE", tmpHomeDir)
t.Setenv("XDG_CONFIG_HOME", filepath.Join(tmpHomeDir, ".config"))

err = os.MkdirAll(filepath.Join(tmpHomeDir, ".ddev"), 0755)
assert.NoError(err)

// Make sure that the $XDG_CONFIG_HOME/ddev doesn't exist before we run ddev.
_, err = os.Stat(filepath.Join(tmpHomeDir, "Library", "Application Support", "ddev"))
_, err = os.Stat(filepath.Join(tmpHomeDir, ".config", "ddev"))
require.Error(t, err)
assert.True(os.IsNotExist(err))

out, err := exec.RunHostCommand(DdevBin, "config", "--auto")
require.NoError(t, err, "failed to ddev config --auto, out=%v, err=%v", out, err)

// $XDG_CONFIG_HOME/ddev should still not exist
_, err = os.Stat(filepath.Join(tmpHomeDir, "Library", "Application Support", "ddev"))
_, err = os.Stat(filepath.Join(tmpHomeDir, ".config", "ddev"))
require.Error(t, err)
assert.True(os.IsNotExist(err))
}
Expand Down

0 comments on commit a95bba1

Please sign in to comment.