Skip to content

Commit d58b8ff

Browse files
committed
Transaction tests
1 parent db24c6a commit d58b8ff

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
defmodule Blog.AccountsTest do
2+
use Blog.DataCase
3+
4+
alias Blog.Accounts
5+
6+
test "create_user/1 returns {:error, changeset} and rolles back transaction on error" do
7+
attrs = %{
8+
contact: %{type: "phone", value: "+1 000 000 0000"},
9+
name: "",
10+
password: "password"
11+
}
12+
13+
contact_count = Repo.aggregate(Accounts.Contact, :count, :id)
14+
15+
assert {:error, %Ecto.Changeset{}} = Accounts.create_user(attrs)
16+
assert ^contact_count = Repo.aggregate(Accounts.Contact, :count, :id)
17+
end
18+
end

0 commit comments

Comments
 (0)