mirror of
https://github.com/philomena-dev/philomena.git
synced 2024-11-27 21:47:59 +01:00
62 lines
1.8 KiB
Elixir
62 lines
1.8 KiB
Elixir
defmodule Philomena.ReportsTest do
|
|
use Philomena.DataCase
|
|
|
|
alias Philomena.Reports
|
|
|
|
describe "reports" do
|
|
alias Philomena.Reports.Report
|
|
|
|
@valid_attrs %{}
|
|
@update_attrs %{}
|
|
@invalid_attrs %{}
|
|
|
|
def report_fixture(attrs \\ %{}) do
|
|
{:ok, report} =
|
|
attrs
|
|
|> Enum.into(@valid_attrs)
|
|
|> Reports.create_report()
|
|
|
|
report
|
|
end
|
|
|
|
test "list_reports/0 returns all reports" do
|
|
report = report_fixture()
|
|
assert Reports.list_reports() == [report]
|
|
end
|
|
|
|
test "get_report!/1 returns the report with given id" do
|
|
report = report_fixture()
|
|
assert Reports.get_report!(report.id) == report
|
|
end
|
|
|
|
test "create_report/1 with valid data creates a report" do
|
|
assert {:ok, %Report{} = report} = Reports.create_report(@valid_attrs)
|
|
end
|
|
|
|
test "create_report/1 with invalid data returns error changeset" do
|
|
assert {:error, %Ecto.Changeset{}} = Reports.create_report(@invalid_attrs)
|
|
end
|
|
|
|
test "update_report/2 with valid data updates the report" do
|
|
report = report_fixture()
|
|
assert {:ok, %Report{} = report} = Reports.update_report(report, @update_attrs)
|
|
end
|
|
|
|
test "update_report/2 with invalid data returns error changeset" do
|
|
report = report_fixture()
|
|
assert {:error, %Ecto.Changeset{}} = Reports.update_report(report, @invalid_attrs)
|
|
assert report == Reports.get_report!(report.id)
|
|
end
|
|
|
|
test "delete_report/1 deletes the report" do
|
|
report = report_fixture()
|
|
assert {:ok, %Report{}} = Reports.delete_report(report)
|
|
assert_raise Ecto.NoResultsError, fn -> Reports.get_report!(report.id) end
|
|
end
|
|
|
|
test "change_report/1 returns a report changeset" do
|
|
report = report_fixture()
|
|
assert %Ecto.Changeset{} = Reports.change_report(report)
|
|
end
|
|
end
|
|
end
|