Created
October 17, 2016 09:50
-
-
Save harfangk/1ce16141033e7895847717d1be66e9b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
==================================================================================== | |
new test: | |
test "converts unique_constraint on username to error" do | |
%User{} | |
|> User.registration_changeset(@valid_attrs) | |
|> Repo.insert!() | |
Repo.all(User) | |
|> IO.inspect() | |
attrs = Map.put(@test_attrs, :username, "user") | |
changeset = User.registration_changeset(%User{}, attrs) | |
assert {:error, changeset} = Repo.insert(changeset) | |
assert {:username, {"has already been taken", []}} in changeset.errors | |
end | |
================================================================================================ | |
result: | |
[%Storybook.User{__meta__: #Ecto.Schema.Metadata<:loaded, "users">, | |
email: "[email protected]", id: 30, | |
inserted_at: #Ecto.DateTime<2016-10-17 09:47:00>, name: nil, password: nil, | |
password_hash: "$2b$12$j2xU4omjt3YYyxr5cl35e.L6B79dobbOI7bTjuUtIyyDy8JUskb.K", | |
updated_at: #Ecto.DateTime<2016-10-17 09:47:00>, username: "user"}] | |
and test passes. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment