Merge pull request #380 from bcwaldon/drop-prevValue

fix(v2): Drop prevValue from exported fields
This commit is contained in:
Brandon Philips
2013-12-06 14:11:01 -08:00
5 changed files with 5 additions and 10 deletions

View File

@@ -24,6 +24,6 @@ func TestV2DeleteKey(t *testing.T) {
resp, err = tests.DeleteForm(fmt.Sprintf("%s%s", s.URL(), "/v2/keys/foo/bar"), url.Values{})
body := tests.ReadBody(resp)
assert.Nil(t, err, "")
assert.Equal(t, string(body), `{"action":"delete","node":{"key":"/foo/bar","prevValue":"XXX","modifiedIndex":3,"createdIndex":2}}`, "")
assert.Equal(t, string(body), `{"action":"delete","node":{"key":"/foo/bar","modifiedIndex":3,"createdIndex":2}}`, "")
})
}

View File

@@ -118,9 +118,6 @@ func TestV2UpdateKeySuccess(t *testing.T) {
resp, _ = tests.PutForm(fmt.Sprintf("%s%s", s.URL(), "/v2/keys/foo/bar"), v)
body := tests.ReadBodyJSON(resp)
assert.Equal(t, body["action"], "update", "")
node := body["node"].(map[string]interface{})
assert.Equal(t, node["prevValue"], "XXX", "")
})
}
@@ -178,7 +175,6 @@ func TestV2SetKeyCASOnIndexSuccess(t *testing.T) {
body := tests.ReadBodyJSON(resp)
assert.Equal(t, body["action"], "compareAndSwap", "")
node := body["node"].(map[string]interface{})
assert.Equal(t, node["prevValue"], "XXX", "")
assert.Equal(t, node["value"], "YYY", "")
assert.Equal(t, node["modifiedIndex"], 3, "")
})
@@ -240,7 +236,6 @@ func TestV2SetKeyCASOnValueSuccess(t *testing.T) {
body := tests.ReadBodyJSON(resp)
assert.Equal(t, body["action"], "compareAndSwap", "")
node := body["node"].(map[string]interface{})
assert.Equal(t, node["prevValue"], "XXX", "")
assert.Equal(t, node["value"], "YYY", "")
assert.Equal(t, node["modifiedIndex"], 3, "")
})

View File

@@ -10,7 +10,7 @@ import (
// TTL is time to live in second
type NodeExtern struct {
Key string `json:"key, omitempty"`
PrevValue string `json:"prevValue,omitempty"`
PrevValue string `json:"-"`
Value string `json:"value,omitempty"`
Dir bool `json:"dir,omitempty"`
Expiration *time.Time `json:"expiration,omitempty"`

View File

@@ -54,7 +54,7 @@ func templateTestSimpleMultiNode(t *testing.T, tls bool) {
result, err = c.Set("foo", "bar", 100)
node = result.Node
if err != nil || node.Key != "/foo" || node.Value != "bar" || node.PrevValue != "bar" || node.TTL < 95 {
if err != nil || node.Key != "/foo" || node.Value != "bar" || node.TTL < 95 {
if err != nil {
t.Fatal(err)
}

View File

@@ -43,7 +43,7 @@ func TestSingleNode(t *testing.T) {
result, err = c.Set("foo", "bar", 100)
node = result.Node
if err != nil || node.Key != "/foo" || node.Value != "bar" || node.PrevValue != "bar" || node.TTL != 100 {
if err != nil || node.Key != "/foo" || node.Value != "bar" || node.TTL != 100 {
if err != nil {
t.Fatal("Set 2: ", err)
}
@@ -56,7 +56,7 @@ func TestSingleNode(t *testing.T) {
result, err = c.CompareAndSwap("foo", "foobar", 100, "bar", 0)
node = result.Node
if err != nil || node.Key != "/foo" || node.Value != "foobar" || node.PrevValue != "bar" || node.TTL != 100 {
if err != nil || node.Key != "/foo" || node.Value != "foobar" || node.TTL != 100 {
if err != nil {
t.Fatal(err)
}