Create_user function is throwing wire following error.
`** (Postgrex.Error) ERROR 22021 (character_not_in_repertoire): invalid byte sequence for encoding "UTF8": 0xb3`
Its basic scaffold code generated from context. Error is thrown only while running test, works fine in console or while seeding data.
This is the data I am passing
%{
"confirmation_token" => "1b66163b-c29a-483e-b37c-a72ac1194a82",
"email" => "email-0@example.com",
"fullname" => "User name",
"password" => "password",
"password_confirmation" => "password",
"state" => "incomplete",
"username" => "username"
}
User schema:
schema "users" do
field(:about, :string)
field(:confirmation_sent_at, :string)
field(:confirmation_token, :binary_id, read_after_write: true)
field(:confirmed_at, :utc_datetime)
field(:email, :string)
field(:failed_attempts, :integer)
field(:fullname, :string)
field(:locked_at, :utc_datetime)
field(:password_hash, :string)
field(:profile_picture, :string)
field(:reset_password_sent_at, :string)
field(:reset_password_token, :string)
field(:sign_in_count, :integer)
field(:state, :string, default: "incomplete")
field(:unlock_token, :string)
field(:username, :string)
field(:password, :string, virtual: true)
field(:password_confirmation, :string, virtual: true)
timestamps()
end
Test code
attrs = params_for(:user)
assert {:ok, user} = Account.create_account(attrs)
Create account code
def create_account(attrs, opts \\ []) do
attrs
|> Zion.Utils.reduce_map_keys_to_string()
|> Map.take(["fullname", "email", "password", "password_confirmation", "username"])
|> add_state(opts)
|> add_confirmation_token
|> UserRepo.create_user()
|> send_confirmation_email(opts)
end
Anyone???