Add a test for safe_jsonb_set
authorrinpatch <rinpatch@sdf.org>
Fri, 18 Oct 2019 11:33:51 +0000 (14:33 +0300)
committerrinpatch <rinpatch@sdf.org>
Fri, 18 Oct 2019 11:33:51 +0000 (14:33 +0300)
test/safe_jsonb_set_test.exs [new file with mode: 0644]

diff --git a/test/safe_jsonb_set_test.exs b/test/safe_jsonb_set_test.exs
new file mode 100644 (file)
index 0000000..7485405
--- /dev/null
@@ -0,0 +1,12 @@
+defmodule Pleroma.SafeJsonbSetTest do
+  use Pleroma.DataCase
+
+  test "it doesn't wipe the object when asked to set the value to NULL" do
+    assert %{rows: [[%{"key" => "value", "test" => nil}]]} =
+             Ecto.Adapters.SQL.query!(
+               Pleroma.Repo,
+               "select safe_jsonb_set('{\"key\": \"value\"}'::jsonb, '{test}', NULL);",
+               []
+             )
+  end
+end