test: add new test verifying batch destroy behavior

chore: add sobelow warning skip
This commit is contained in:
Zach Daniel 2024-02-01 13:09:06 -05:00
parent d71cb81792
commit b018262637
3 changed files with 13 additions and 3 deletions

View file

@ -72,13 +72,13 @@ defmodule AshPostgres.CustomIndex do
def schema, do: @schema
# sobelow_skip ["DOS.StringToAtom"]
def transform(index) do
with {:ok, index} <- set_name(index) do
set_error_fields(index)
end
end
# sobelow_skip ["DOS.StringToAtom"]
defp set_error_fields(index) do
if index.error_fields do
{:ok, index}

View file

@ -158,7 +158,7 @@ defmodule AshPostgres.MixProject do
{:jason, "~> 1.0"},
{:postgrex, ">= 0.0.0"},
{:ash,
ash_version(github: "ash-project/ash", ref: "3b3e3a06f26a1cb43d69e1e470a462c37fb84987")},
ash_version(github: "ash-project/ash", ref: "57654d3df49d39fe727bd86df3a0496c8598c7c1")},
{:benchee, "~> 1.1", only: [:dev, :test]},
{:git_ops, "~> 2.5", only: [:dev, :test]},
{:ex_doc, github: "elixir-lang/ex_doc", only: [:dev, :test], runtime: false},

View file

@ -17,7 +17,7 @@ defmodule AshPostgres.BulkDestroyTest do
assert Api.read!(Post) == []
end
test "bulk updates only apply to things that the query produces" do
test "bulk destroys only apply to things that the query produces" do
Api.bulk_create!([%{title: "fred"}, %{title: "george"}], Post, :create)
Post
@ -27,4 +27,14 @@ defmodule AshPostgres.BulkDestroyTest do
# 😢 sad
assert [%{title: "george"}] = Api.read!(Post)
end
test "bulk destroys can be done even on stream inputs" do
Api.bulk_create!([%{title: "fred"}, %{title: "george"}], Post, :create)
Post
|> Api.read!()
|> Api.bulk_destroy!(:destroy, %{})
assert [] = Api.read!(Post)
end
end