Skip to content

Commit

Permalink
adds tests #45
Browse files Browse the repository at this point in the history
  • Loading branch information
RobStallion committed Mar 1, 2019
1 parent 65f898e commit 0c11e6f
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions test/insert_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,24 @@ defmodule AlogTest.InsertTest do
describe "Repo.insert/2 - with Comment struct:" do
test "succeeds" do
Repo.insert(%Comment{comment: "hi"})
|> IO.inspect(label: "===> Result of insert")
num_comments = Comment |> Repo.all() |> length()
assert num_comments == 1
end

test "inserting the same comment twice fails with changeset" do
Repo.insert(%Comment{comment: "hi"})

{atom, _changeset} =
%Comment{}
|> Comment.changeset(%{comment: "hi"})
|> Repo.insert()

Repo.all(Comment)
|> IO.inspect(label: "===> All comments (should only be the one)")
assert atom == :error
end

test "inserting the same comment twice fails without changeset" do
Repo.insert(%Comment{comment: "hi"})
Repo.insert(%Comment{comment: "hi"})
end

# test "validates required fields" do
Expand Down

0 comments on commit 0c11e6f

Please sign in to comment.