Pleroma/test/support/builders/user_builder.ex
Haelwenn (lanodan) Monnier 8bb7e19b38
test: de-group alias/es
2019-02-11 03:44:15 +01:00

24 lines
491 B
Elixir

defmodule Pleroma.Builders.UserBuilder do
alias Pleroma.User
alias Pleroma.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