summaryrefslogtreecommitdiff
path: root/test/config/config_db_test.exs
diff options
context:
space:
mode:
authorAlexander Strizhakov <alex.strizhakov@gmail.com>2020-01-18 12:25:56 +0300
committerAlexander Strizhakov <alex.strizhakov@gmail.com>2020-01-18 12:25:56 +0300
commite69986169095796f2845c4f859234d96f91bf9ff (patch)
treeee64255b674c622c7ef3545263c2784f69c7f585 /test/config/config_db_test.exs
parent89e93fb33f6295428dd84a50c9ca44e26bd169c3 (diff)
downloadpleroma-e69986169095796f2845c4f859234d96f91bf9ff.tar.gz
pleroma-e69986169095796f2845c4f859234d96f91bf9ff.zip
full update for some subkeys
Diffstat (limited to 'test/config/config_db_test.exs')
-rw-r--r--test/config/config_db_test.exs34
1 files changed, 34 insertions, 0 deletions
diff --git a/test/config/config_db_test.exs b/test/config/config_db_test.exs
index 7668bc547..19619620e 100644
--- a/test/config/config_db_test.exs
+++ b/test/config/config_db_test.exs
@@ -155,6 +155,40 @@ defmodule Pleroma.ConfigDBTest do
assert ConfigDB.from_binary(updated.value) == Tesla.Adapter.Httpc
end
+
+ test "only full update for some subkeys" do
+ config1 =
+ insert(:config,
+ key: ":emoji",
+ value: ConfigDB.to_binary(groups: [a: 1, b: 2], key: [a: 1])
+ )
+
+ config2 =
+ insert(:config,
+ key: ":assets",
+ value: ConfigDB.to_binary(mascots: [a: 1, b: 2], key: [a: 1])
+ )
+
+ {:ok, _config} =
+ ConfigDB.update_or_create(%{
+ group: config1.group,
+ key: config1.key,
+ value: [groups: [c: 3, d: 4], key: [b: 2]]
+ })
+
+ {:ok, _config} =
+ ConfigDB.update_or_create(%{
+ group: config2.group,
+ key: config2.key,
+ value: [mascots: [c: 3, d: 4], key: [b: 2]]
+ })
+
+ updated1 = ConfigDB.get_by_params(%{group: config1.group, key: config1.key})
+ updated2 = ConfigDB.get_by_params(%{group: config2.group, key: config2.key})
+
+ assert ConfigDB.from_binary(updated1.value) == [groups: [c: 3, d: 4], key: [a: 1, b: 2]]
+ assert ConfigDB.from_binary(updated2.value) == [mascots: [c: 3, d: 4], key: [a: 1, b: 2]]
+ end
end
test "delete/1" do