Fix v1 cluster migration test.

This commit is contained in:
Ben Johnson 2013-11-12 19:22:09 -05:00
parent ccc27a61f5
commit 954217fb73
9 changed files with 14 additions and 14 deletions

View File

@ -8,7 +8,7 @@ import (
// Removes a key from the store.
func DeleteKeyHandler(w http.ResponseWriter, req *http.Request, s Server) error {
vars := mux.Vars(req)
key := vars["key"]
key := "/" + vars["key"]
c := s.Store().CommandFactory().CreateDeleteCommand(key, false)
return s.Dispatch(c, w, req)
}

View File

@ -10,7 +10,7 @@ import (
// Retrieves the value for a given key.
func GetKeyHandler(w http.ResponseWriter, req *http.Request, s Server) error {
vars := mux.Vars(req)
key := vars["key"]
key := "/" + vars["key"]
// Retrieve the key from the store.
event, err := s.Store().Get(key, false, false)

View File

@ -12,7 +12,7 @@ import (
// Sets the value for a given key.
func SetKeyHandler(w http.ResponseWriter, req *http.Request, s Server) error {
vars := mux.Vars(req)
key := vars["key"]
key := "/" + vars["key"]
req.ParseForm()

View File

@ -13,7 +13,7 @@ import (
func WatchKeyHandler(w http.ResponseWriter, req *http.Request, s Server) error {
var err error
vars := mux.Vars(req)
key := vars["key"]
key := "/" + vars["key"]
// Create a command to watch from a given index (default 0).
var sinceIndex uint64 = 0

View File

@ -8,7 +8,7 @@ import (
func DeleteHandler(w http.ResponseWriter, req *http.Request, s Server) error {
vars := mux.Vars(req)
key := vars["key"]
key := "/" + vars["key"]
recursive := (req.FormValue("recursive") == "true")
c := s.Store().CommandFactory().CreateDeleteCommand(key, recursive)

View File

@ -18,7 +18,7 @@ func GetHandler(w http.ResponseWriter, req *http.Request, s Server) error {
var event *store.Event
vars := mux.Vars(req)
key := vars["key"]
key := "/" + vars["key"]
// Help client to redirect the request to the current leader
if req.FormValue("consistent") == "true" && s.State() != raft.Leader {

View File

@ -10,7 +10,7 @@ import (
func PostHandler(w http.ResponseWriter, req *http.Request, s Server) error {
vars := mux.Vars(req)
key := vars["key"]
key := "/" + vars["key"]
value := req.FormValue("value")
expireTime, err := store.TTL(req.FormValue("ttl"))

View File

@ -15,7 +15,7 @@ func PutHandler(w http.ResponseWriter, req *http.Request, s Server) error {
var c raft.Command
vars := mux.Vars(req)
key := vars["key"]
key := "/" + vars["key"]
req.ParseForm()

View File

@ -87,17 +87,17 @@ func TestV1ClusterMigration(t *testing.T) {
time.Sleep(time.Second)
}
time.Sleep(120 * time.Second)
// Ensure deleted message is removed.
resp, err := tests.Get("http://localhost:4001/v2/keys/message")
tests.ReadBody(resp)
body := tests.ReadBody(resp)
assert.Nil(t, err, "")
assert.Equal(t, resp.StatusCode, 404, "")
assert.Equal(t, resp.StatusCode, 400, )
assert.Equal(t, string(body), `{"errorCode":100,"message":"Key Not Found","cause":"/message","index":11}`+"\n")
// Ensure TTL'd message is removed.
resp, err = tests.Get("http://localhost:4001/v2/keys/foo")
tests.ReadBody(resp)
body = tests.ReadBody(resp)
assert.Nil(t, err, "")
assert.Equal(t, resp.StatusCode, 404, "")
assert.Equal(t, resp.StatusCode, 200, "")
assert.Equal(t, string(body), `{"action":"get","key":"/foo","value":"one","modifiedIndex":9}`)
}