Browse Source

etcd: use tmpDir as testing directory

Xiang Li 11 years ago
parent
commit
12dd380d26
1 changed files with 6 additions and 2 deletions
  1. 6 2
      etcd/etcd_test.go

+ 6 - 2
etcd/etcd_test.go

@@ -342,9 +342,13 @@ func buildCluster(number int, tls bool) ([]*Server, []*httptest.Server) {
 }
 
 func initTestServer(c *config.Config, id int64, tls bool) (e *Server, h *httptest.Server) {
-	c.DataDir = fmt.Sprintf("tests/etcd_%d", id)
+	n, err := ioutil.TempDir(os.TempDir(), "etcd")
+	if err != nil {
+		panic(err)
+	}
+	c.DataDir = n
 
-	e, err := New(c)
+	e, err = New(c)
 	if err != nil {
 		panic(err)
 	}