mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
Merge pull request #524 from yifan-gu/remove_omitempty_on_value
remove omitempty on value
This commit is contained in:
@@ -180,7 +180,7 @@ func (r *Registry) load(name string) {
|
||||
}
|
||||
|
||||
// Parse as a query string.
|
||||
m, err := url.ParseQuery(e.Node.Value)
|
||||
m, err := url.ParseQuery(*e.Node.Value)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("Failed to parse peers entry: %s", name))
|
||||
}
|
||||
|
||||
@@ -329,3 +329,18 @@ func TestV2SetKeyCASWithMissingValueFails(t *testing.T) {
|
||||
assert.Equal(t, body["cause"], "CompareAndSwap", "")
|
||||
})
|
||||
}
|
||||
|
||||
// Ensure that we can set an empty value
|
||||
//
|
||||
// $ curl -X PUT localhost:4001/v2/keys/foo/bar -d value=
|
||||
//
|
||||
func TestV2SetKeyCASWithEmptyValueSuccess(t *testing.T) {
|
||||
tests.RunServer(func(s *server.Server) {
|
||||
v := url.Values{}
|
||||
v.Set("value", "")
|
||||
resp, _ := tests.PutForm(fmt.Sprintf("%s%s", s.URL(), "/v2/keys/foo/bar"), v)
|
||||
assert.Equal(t, resp.StatusCode, http.StatusCreated)
|
||||
body := tests.ReadBody(resp)
|
||||
assert.Equal(t, string(body), `{"action":"set","node":{"key":"/foo/bar","value":"","modifiedIndex":2,"createdIndex":2}}`)
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user