Skip to content

Commit

Permalink
test: add new test case
Browse files Browse the repository at this point in the history
  • Loading branch information
danxmoran committed Jan 13, 2021
1 parent 757e101 commit 4d72afc
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion cmd/influxd/upgrade/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func TestPathValidations(t *testing.T) {
enginePath: enginePath,
}


err = sourceOpts.validatePaths()
require.NotNil(t, err, "Must fail")
assert.Contains(t, err.Error(), "1.x DB dir")
Expand Down Expand Up @@ -74,6 +73,46 @@ func TestPathValidations(t *testing.T) {
assert.Contains(t, err.Error(), "2.x CLI configs")
}

func TestClearTargetPaths(t *testing.T) {
tmpdir, err := ioutil.TempDir("", "")
require.NoError(t, err)

defer os.RemoveAll(tmpdir)

v2Dir := filepath.Join(tmpdir, "v2db")
boltPath := filepath.Join(v2Dir, bolt.DefaultFilename)
configsPath := filepath.Join(v2Dir, "configs")
enginePath := filepath.Join(v2Dir, "engine")
cqPath := filepath.Join(v2Dir, "cqs")
configPath := filepath.Join(v2Dir, "config")

err = os.MkdirAll(filepath.Join(enginePath, "db"), 0777)
require.NoError(t, err)
err = ioutil.WriteFile(boltPath, []byte{1}, 0777)
require.NoError(t, err)
err = ioutil.WriteFile(configsPath, []byte{1}, 0777)
require.NoError(t, err)
err = ioutil.WriteFile(cqPath, []byte{1}, 0777)
require.NoError(t, err)
err = ioutil.WriteFile(configPath, []byte{1}, 0777)
require.NoError(t, err)

targetOpts := &optionsV2{
boltPath: boltPath,
cliConfigsPath: configsPath,
enginePath: enginePath,
configPath: configPath,
cqPath: cqPath,
}

err = targetOpts.validatePaths()
require.Error(t, err)
err = targetOpts.clearPaths()
require.NoError(t, err)
err = targetOpts.validatePaths()
require.NoError(t, err)
}

func TestDbURL(t *testing.T) {

type testCase struct {
Expand Down

0 comments on commit 4d72afc

Please sign in to comment.