fix(etcd): Fix forced config reset
When a server name or a data directory were not provided, the reset functionality would fail to clear out config files from the appropriate place. This calcualtes the default server name and data directory before reset is called.
This commit is contained in:

committed by
Brandon Philips

parent
73f04d5cec
commit
e7839e8c57
@ -313,6 +313,24 @@ func TestConfigNameFlag(t *testing.T) {
|
||||
assert.Equal(t, c.Name, "test-name", "")
|
||||
}
|
||||
|
||||
// Ensures that a Name gets guessed if not specified
|
||||
func TestConfigNameGuess(t *testing.T) {
|
||||
c := NewConfig()
|
||||
assert.Nil(t, c.LoadFlags([]string{}), "")
|
||||
assert.Nil(t, c.Sanitize())
|
||||
name, _ := os.Hostname()
|
||||
assert.Equal(t, c.Name, name, "")
|
||||
}
|
||||
|
||||
// Ensures that a DataDir gets guessed if not specified
|
||||
func TestConfigDataDirGuess(t *testing.T) {
|
||||
c := NewConfig()
|
||||
assert.Nil(t, c.LoadFlags([]string{}), "")
|
||||
assert.Nil(t, c.Sanitize())
|
||||
name, _ := os.Hostname()
|
||||
assert.Equal(t, c.DataDir, name+".etcd", "")
|
||||
}
|
||||
|
||||
// Ensures that Snapshot can be parsed from the environment.
|
||||
func TestConfigSnapshotEnv(t *testing.T) {
|
||||
withEnv("ETCD_SNAPSHOT", "1", func(c *Config) {
|
||||
|
Reference in New Issue
Block a user