postland/test/support/fixtures/accounts_fixtures.ex

28 lines
658 B
Elixir
Raw Normal View History

2024-09-20 19:30:46 +00:00
defmodule Postland.AccountsFixtures do
@moduledoc """
This module defines test helpers for creating
entities via the `Postland.Accounts` context.
"""
def unique_user_username, do: "user#{System.unique_integer([:positive])}"
def valid_user_password, do: "hello world!"
def valid_user_attributes(attrs \\ %{}) do
Enum.into(attrs, %{
username: unique_user_username(),
2024-09-24 13:16:54 +00:00
password: valid_user_password(),
private_key: "test",
public_key: "test"
2024-09-20 19:30:46 +00:00
})
end
def user_fixture(attrs \\ %{}) do
{:ok, user} =
attrs
|> valid_user_attributes()
|> Postland.Accounts.register_user()
user
end
end