Skip to content

Commit

Permalink
Add test to make sure ddev creates ~/.ddev
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay committed Jul 10, 2017
1 parent 2769db0 commit 87a8dcb
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions cmd/ddev/cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/drud/ddev/pkg/testcommon"
"github.com/drud/ddev/pkg/util"

"path/filepath"

"github.com/drud/ddev/pkg/appports"
"github.com/drud/ddev/pkg/exec"
"github.com/drud/ddev/pkg/plugins/platform"
Expand Down Expand Up @@ -82,6 +84,39 @@ func TestGetActiveAppRoot(t *testing.T) {
switchDir()
}

// TestCreateGlobalDdevDir checks to make sure that ddev will create a ~/.ddev (and updatecheck)
func TestCreateGlobalDdevDir(t *testing.T) {
tmpDir := testcommon.CreateTmpDir("globalDdevCheck")
origHome := os.Getenv("HOME")

// Make sure that the tmpDir/.ddev and tmpDir/.ddev/.update don't exist before we run ddev.
_, err := os.Stat(filepath.Join(tmpDir, ".ddev"))
assert.Error(t, err)
assert.True(t, os.IsNotExist(err))

_, err = os.Stat(filepath.Join(tmpDir, ".ddev", ".update"))
assert.Error(t, err)
assert.True(t, os.IsNotExist(err))

// Change the homedir temporarily
err = os.Setenv("HOME", tmpDir)
assert.NoError(t, err)

args := []string{}
_, err = exec.RunCommand(DdevBin, args)
assert.NoError(t, err)

_, err = os.Stat(filepath.Join(tmpDir, ".ddev", ".update"))
assert.NoError(t, err)

// Cleanup our tmp homedir
err = os.RemoveAll(tmpDir)
assert.NoError(t, err)

err = os.Setenv("HOME", origHome)
assert.NoError(t, err)
}

// addSites runs `ddev start` on the test apps
func addSites() {
for _, site := range DevTestSites {
Expand Down

0 comments on commit 87a8dcb

Please sign in to comment.