Browse Source

fix bug of deleteing the root

evan-gu 12 years ago
parent
commit
09414016c2
3 changed files with 38 additions and 0 deletions
  1. 1 0
      etcd_handlers.go
  2. 1 0
      file_system/file_system.go
  3. 36 0
      transporter_test.go

+ 1 - 0
etcd_handlers.go

@@ -169,6 +169,7 @@ func UpdateHttpHandler(w http.ResponseWriter, req *http.Request) error {
 // Delete Handler
 func DeleteHttpHandler(w http.ResponseWriter, req *http.Request) error {
 	key := req.URL.Path[len("/v2/keys"):]
+	
 	debugf("recv.delete[%v] [%v%v]\n", req.RemoteAddr, req.Host, req.URL)
 
 	command := &DeleteCommand{

+ 1 - 0
file_system/file_system.go

@@ -244,6 +244,7 @@ func (fs *FileSystem) Delete(nodePath string, recursive bool, index uint64, term
 	}
 
 	fs.WatcherHub.notify(e)
+	
 	return e, nil
 }
 

+ 36 - 0
transporter_test.go

@@ -0,0 +1,36 @@
+package main
+
+import (
+	"crypto/tls"
+	"testing"
+	"time"
+)
+
+func TestTransporterTimeout(t *testing.T) {
+
+	conf := tls.Config{}
+
+	ts := newTransporter("http", conf, time.Second)
+
+	ts.Get("http://google.com")
+	_, err := ts.Get("http://google.com:9999") // it doesn't exisit
+	if err == nil || err.Error() != "Wait Response Timeout: 1s" {
+		t.Fatal("timeout error: ", err.Error())
+	}
+
+	_, err = ts.Post("http://google.com:9999", nil) // it doesn't exisit
+	if err == nil || err.Error() != "Wait Response Timeout: 1s" {
+		t.Fatal("timeout error: ", err.Error())
+	}
+
+	_, err = ts.Get("http://www.google.com")
+	if err != nil {
+		t.Fatal("get error")
+	}
+
+	_, err = ts.Post("http://www.google.com", nil)
+	if err != nil {
+		t.Fatal("post error")
+	}
+
+}