1
0
mirror of https://git.pleroma.social/sjw/pleroma.git synced 2024-12-29 15:45:33 +01:00
pleroma/test/support/builders/user_builder.ex
2018-03-30 15:01:53 +02:00

23 lines
478 B
Elixir

defmodule Pleroma.Builders.UserBuilder do
alias Pleroma.{User, Repo}
def build(data \\ %{}) do
user = %User{
email: "test@example.org",
name: "Test Name",
nickname: "testname",
password_hash: Comeonin.Pbkdf2.hashpwsalt("test"),
bio: "A tester.",
ap_id: "some id"
}
Map.merge(user, data)
end
def insert(data \\ %{}) do
{:ok, user} = Repo.insert(build(data))
User.invalidate_cache(user)
{:ok, user}
end
end