I wrote a doctest that tests that the function is returning a %Foobar.Accounts.User struct type.
1) test doc at Foobar.Accounts.create_user_with_email_only/1 (1) (Foobar.AccountsTest)
test/accounts/accounts_test.exs:3
Doctest failed
code: Foobar.Accounts.create_user_with_email_only("test@email.com") === {:ok, %Foobar.Accounts.User{}}
left: {:ok,
%Foobar.Accounts.User{__meta__: #Ecto.Schema.Metadata<:loaded, "users">,
confirmation_code: "338128", email: "test@email.com",
email_confirmed: false, encrypted_password: nil, fullname: nil,
id: 2306, inserted_at: ~N[2017-07-25 03:26:15.407053],
invite_token: nil, onboarded: false, password: nil, pin: nil,
roles: nil,
team: #Ecto.Association.NotLoaded<association :team is not loaded>,
team_id: nil, token: "flDJRP6Vx78pI3uSOgSVPb2HxcEZ3DYU",
updated_at: ~N[2017-07-25 03:26:15.413361], username: nil}}
stacktrace:
lib/accounts/accounts.ex:15: Foobar.Accounts (module)
My doctests look like:
@doc """
Create a user with only the email field set. The user is not
associated with any team.
## Examples
iex> Foobar.Accounts.create_user_with_email_only("test@email.com")
{:ok, %Foobar.Accounts.User{}}
iex> Foobar.Accounts.create_user_with_email_only("")
{:error, "Email cannot be blank or nil."}
iex> Foobar.Accounts.create_user_with_email_only(nil)
{:error, "Email cannot be blank or nil."}
"""
def create_user_with_email_only(email) when byte_size(email) > 0 do
Thanks for the help!