pleroma/test/support/builders/user_builder.ex

24 lines
491 B
Elixir
Raw Normal View History

2017-03-21 16:53:20 +00:00
defmodule Pleroma.Builders.UserBuilder do
2019-02-10 21:57:38 +00:00
alias Pleroma.Repo
alias Pleroma.User
2017-03-21 16:53:20 +00:00
2017-03-22 15:51:20 +00:00
def build(data \\ %{}) do
user = %User{
2017-03-21 16:53:20 +00:00
email: "test@example.org",
name: "Test Name",
nickname: "testname",
password_hash: Comeonin.Pbkdf2.hashpwsalt("test"),
bio: "A tester.",
ap_id: "some id"
}
2018-03-30 13:01:53 +00:00
2017-03-22 15:51:20 +00:00
Map.merge(user, data)
2017-03-21 16:53:20 +00:00
end
2017-03-22 15:51:20 +00:00
def insert(data \\ %{}) do
2018-02-25 17:08:41 +00:00
{:ok, user} = Repo.insert(build(data))
User.invalidate_cache(user)
{:ok, user}
2017-03-21 16:53:20 +00:00
end
end