Skip to content

Commit 5878e1c

Browse files
committed
Added test for copying from invalid index
1 parent c5bbc36 commit 5878e1c

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

test/jsonpatch/operation/copy_test.exs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,17 @@ defmodule Jsonpatch.Operation.CopyTest do
126126
assert %{"a" => [999, 999]} = patched
127127
end
128128

129-
test "Copy list element with invalid index" do
129+
test "Copy list element from invalid index" do
130+
patch = %Copy{from: "/a/6", path: "/a/0"}
131+
132+
target = %{"a" => [999, 888]}
133+
134+
patched_error = Operation.apply_op(patch, target)
135+
136+
assert {:error, :invalid_index, "6"} = patched_error
137+
end
138+
139+
test "Copy list element to invalid index" do
130140
patch = %Copy{from: "/a/0", path: "/a/5"}
131141

132142
target = %{"a" => [999, 888]}

0 commit comments

Comments
 (0)