|
|
@@ -15,7 +15,6 @@
|
|
|
package main
|
|
|
|
|
|
import (
|
|
|
- "io/ioutil"
|
|
|
"os"
|
|
|
"path/filepath"
|
|
|
"syscall"
|
|
|
@@ -27,10 +26,10 @@ var etcdPath = filepath.Join(os.Getenv("GOPATH"), "bin/etcd")
|
|
|
func TestAgentStart(t *testing.T) {
|
|
|
defer os.Remove("etcd.log")
|
|
|
|
|
|
- a, dir := newTestAgent(t)
|
|
|
+ a := newTestAgent(t)
|
|
|
defer a.terminate()
|
|
|
|
|
|
- err := a.start("--data-dir", dir)
|
|
|
+ err := a.start()
|
|
|
if err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
@@ -39,10 +38,10 @@ func TestAgentStart(t *testing.T) {
|
|
|
func TestAgentRestart(t *testing.T) {
|
|
|
defer os.Remove("etcd.log")
|
|
|
|
|
|
- a, dir := newTestAgent(t)
|
|
|
+ a := newTestAgent(t)
|
|
|
defer a.terminate()
|
|
|
|
|
|
- err := a.start("--data-dir", dir)
|
|
|
+ err := a.start()
|
|
|
if err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
@@ -60,9 +59,9 @@ func TestAgentRestart(t *testing.T) {
|
|
|
func TestAgentTerminate(t *testing.T) {
|
|
|
defer os.Remove("etcd.log")
|
|
|
|
|
|
- a, dir := newTestAgent(t)
|
|
|
+ a := newTestAgent(t)
|
|
|
|
|
|
- err := a.start("--data-dir", dir)
|
|
|
+ err := a.start()
|
|
|
if err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
@@ -72,21 +71,17 @@ func TestAgentTerminate(t *testing.T) {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
|
|
|
- if _, err := os.Stat(dir); !os.IsNotExist(err) {
|
|
|
+ if _, err := os.Stat(a.dataDir()); !os.IsNotExist(err) {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// newTestAgent creates a test agent and with a temp data directory.
|
|
|
-func newTestAgent(t *testing.T) (*Agent, string) {
|
|
|
+// newTestAgent creates a test agent
|
|
|
+func newTestAgent(t *testing.T) *Agent {
|
|
|
a, err := newAgent(AgentConfig{EtcdPath: etcdPath, LogDir: "etcd.log"})
|
|
|
if err != nil {
|
|
|
t.Fatal(err)
|
|
|
}
|
|
|
|
|
|
- dir, err := ioutil.TempDir(os.TempDir(), "etcd-agent")
|
|
|
- if err != nil {
|
|
|
- t.Fatal(err)
|
|
|
- }
|
|
|
- return a, dir
|
|
|
+ return a
|
|
|
}
|