mirror of https://github.com/status-im/consul.git
Fix one more unit test that created a config file
This commit is contained in:
parent
a286ad7533
commit
a4331a480c
|
@ -7,6 +7,9 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
"github.com/hashicorp/consul/testutil"
|
"github.com/hashicorp/consul/testutil"
|
||||||
"github.com/hashicorp/serf/serf"
|
"github.com/hashicorp/serf/serf"
|
||||||
)
|
)
|
||||||
|
@ -54,11 +57,14 @@ func TestAPI_AgentReload(t *testing.T) {
|
||||||
t.Parallel()
|
t.Parallel()
|
||||||
|
|
||||||
// Create our initial empty config file, to be overwritten later
|
// Create our initial empty config file, to be overwritten later
|
||||||
configFile := testutil.TempFile(t, "reload")
|
cfgDir := testutil.TempDir(t, "consul-config")
|
||||||
if _, err := configFile.Write([]byte("{}")); err != nil {
|
defer os.RemoveAll(cfgDir)
|
||||||
t.Fatalf("err: %s", err)
|
|
||||||
|
cfgFilePath := filepath.Join(cfgDir, "reload.json")
|
||||||
|
configFile, err := os.Create(cfgFilePath)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Unable to create file %v, got error:%v", cfgFilePath, err)
|
||||||
}
|
}
|
||||||
configFile.Close()
|
|
||||||
|
|
||||||
c, s := makeClientWithConfig(t, nil, func(conf *testutil.TestServerConfig) {
|
c, s := makeClientWithConfig(t, nil, func(conf *testutil.TestServerConfig) {
|
||||||
conf.Args = []string{"-config-file", configFile.Name()}
|
conf.Args = []string{"-config-file", configFile.Name()}
|
||||||
|
@ -69,7 +75,7 @@ func TestAPI_AgentReload(t *testing.T) {
|
||||||
|
|
||||||
// Update the config file with a service definition
|
// Update the config file with a service definition
|
||||||
config := `{"service":{"name":"redis", "port":1234}}`
|
config := `{"service":{"name":"redis", "port":1234}}`
|
||||||
err := ioutil.WriteFile(configFile.Name(), []byte(config), 0644)
|
err = ioutil.WriteFile(configFile.Name(), []byte(config), 0644)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("err: %v", err)
|
t.Fatalf("err: %v", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue