From b237418f2346f63dadf6b95d3023967e11d4bea4 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 5 Aug 2020 17:42:09 +0200 Subject: [PATCH 1/4] Revert "Test for copying null-value key." This reverts commit 266303115221f6a79e03731280f3676b22168d2c. Signed-off-by: Sebastiaan van Stijn --- patch_test.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/patch_test.go b/patch_test.go index 5cd519d..d17ca2e 100644 --- a/patch_test.go +++ b/patch_test.go @@ -186,11 +186,6 @@ var Cases = []Case{ `[{"op": "copy", "path": "/foo/0", "from": "/foo"}]`, `{ "foo": [["bar"], "bar"]}`, }, - { - `{ "foo": null}`, - `[{"op": "copy", "path": "/bar", "from": "/foo"}]`, - `{ "foo": null, "bar": null}`, - }, { `{ "foo": ["bar","qux","baz"]}`, `[ { "op": "remove", "path": "/foo/-2"}]`, From 9b58b85b0b7dff11e5d35a5b484b991c6867ab1f Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 5 Aug 2020 17:42:16 +0200 Subject: [PATCH 2/4] Revert "Test for testing non-existent and null-value keys." This reverts commit c235ce89e1e02a76eac0be921e6e8fe12d9c6120. Signed-off-by: Sebastiaan van Stijn --- patch_test.go | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/patch_test.go b/patch_test.go index d17ca2e..2c03446 100644 --- a/patch_test.go +++ b/patch_test.go @@ -468,18 +468,6 @@ var TestCases = []TestCase{ false, "/foo", }, - { - `{ "foo": "bar" }`, - `[ { "op": "test", "path": "/baz", "value": "bar" } ]`, - false, - "/baz", - }, - { - `{ "foo": "bar" }`, - `[ { "op": "test", "path": "/baz", "value": null } ]`, - true, - "/baz", - }, } func TestAllTest(t *testing.T) { From 42bcdf26fca564b75f23a698b49635b5b2714c8d Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 5 Aug 2020 17:42:21 +0200 Subject: [PATCH 3/4] Revert "Test for copying non-existent key." This reverts commit caa7f266ac971d84049d2a618644979d26114ac8. Signed-off-by: Sebastiaan van Stijn --- patch_test.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/patch_test.go b/patch_test.go index 2c03446..c0567a0 100644 --- a/patch_test.go +++ b/patch_test.go @@ -336,11 +336,6 @@ var BadCases = []BadCase{ `{ "baz": "qux" }`, `[ { "op": "replace", "path": "/foo", "value": "bar" } ]`, }, - // Can't copy from non-existent "from" key. - { - `{ "foo": "bar"}`, - `[{"op": "copy", "path": "/qux", "from": "/baz"}]`, - }, } // This is not thread safe, so we cannot run patch tests in parallel. From 4c18d304a429fb056cb4861df99fbcaa9107164b Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Wed, 5 Aug 2020 17:42:26 +0200 Subject: [PATCH 4/4] Revert "Conform to RFC6902 replacement semantics." This reverts commit a5df74aab0efb032ca893c048330abcad0b78e6f. Signed-off-by: Sebastiaan van Stijn --- patch.go | 10 +++------- patch_test.go | 4 ---- 2 files changed, 3 insertions(+), 11 deletions(-) diff --git a/patch.go b/patch.go index e736759..f185a45 100644 --- a/patch.go +++ b/patch.go @@ -392,17 +392,13 @@ func (d *partialDoc) add(key string, val *lazyNode) error { } func (d *partialDoc) get(key string) (*lazyNode, error) { - v, ok := (*d)[key] - if !ok { - return v, errors.Wrapf(ErrMissing, "unable to get nonexistent key: %s", key) - } - return v, nil + return (*d)[key], nil } func (d *partialDoc) remove(key string) error { _, ok := (*d)[key] if !ok { - return errors.Wrapf(ErrMissing, "unable to remove nonexistent key: %s", key) + return errors.Wrapf(ErrMissing, "Unable to remove nonexistent key: %s", key) } delete(*d, key) @@ -624,7 +620,7 @@ func (p Patch) test(doc *container, op Operation) error { } val, err := con.get(key) - if err != nil && errors.Cause(err) != ErrMissing { + if err != nil { return errors.Wrapf(err, "error in test for path: '%s'", path) } diff --git a/patch_test.go b/patch_test.go index c0567a0..40c9b26 100644 --- a/patch_test.go +++ b/patch_test.go @@ -332,10 +332,6 @@ var BadCases = []BadCase{ `{ "foo": [ "all", "grass", "cows", "eat" ] }`, `[ { "op": "move", "from": "/foo/1", "path": "/foo/4" } ]`, }, - { - `{ "baz": "qux" }`, - `[ { "op": "replace", "path": "/foo", "value": "bar" } ]`, - }, } // This is not thread safe, so we cannot run patch tests in parallel.