config = insert(:config)
insert(:config)
- assert config == Config.get_by_key(config.key)
+ assert config == Config.get_by_params(%{group: config.group, key: config.key})
end
test "create/1" do
- {:ok, config} = Config.create(%{key: "some_key", value: "some_value"})
- assert config == Config.get_by_key("some_key")
+ {:ok, config} = Config.create(%{group: "pleroma", key: "some_key", value: "some_value"})
+ assert config == Config.get_by_params(%{group: "pleroma", key: "some_key"})
end
test "update/1" do
config = insert(:config)
{:ok, updated} = Config.update(config, %{value: "some_value"})
- loaded = Config.get_by_key(config.key)
+ loaded = Config.get_by_params(%{group: config.group, key: config.key})
assert loaded == updated
end
key2 = "another_key"
params = [
- %{key: key2, value: "another_value"},
- %{key: config.key, value: "new_value"}
+ %{group: "pleroma", key: key2, value: "another_value"},
+ %{group: config.group, key: config.key, value: "new_value"}
]
assert Repo.all(Config) |> length() == 1
assert Repo.all(Config) |> length() == 2
- config1 = Config.get_by_key(config.key)
- config2 = Config.get_by_key(key2)
+ config1 = Config.get_by_params(%{group: config.group, key: config.key})
+ config2 = Config.get_by_params(%{group: "pleroma", key: key2})
assert config1.value == Config.transform("new_value")
assert config2.value == Config.transform("another_value")
test "delete/1" do
config = insert(:config)
- {:ok, _} = Config.delete(config.key)
- refute Config.get_by_key(config.key)
+ {:ok, _} = Config.delete(%{key: config.key, group: config.group})
+ refute Config.get_by_params(%{key: config.key, group: config.group})
end
describe "transform/1" do