Midway: test fixes.

This commit is contained in:
codevictory
2021-04-28 20:50:31 +03:00
parent 37f9e1c3f9
commit 607ae59589
4 changed files with 48 additions and 20 deletions

View File

@@ -17,7 +17,8 @@ defmodule Runosaari.RegistrationTest do
date2: true, date2: true,
date3: true, date3: true,
bus: true, bus: true,
accom: true accom: true,
seqnum: 1
} }
@update_attrs %{ @update_attrs %{
confirmed: false, confirmed: false,
@@ -30,7 +31,8 @@ defmodule Runosaari.RegistrationTest do
date2: true, date2: true,
date3: true, date3: true,
bus: true, bus: true,
accom: true accom: true,
seqnum: 2
} }
@invalid_attrs %{ @invalid_attrs %{
confirmed: nil, confirmed: nil,
@@ -43,7 +45,8 @@ defmodule Runosaari.RegistrationTest do
date2: nil, date2: nil,
date3: nil, date3: nil,
bus: nil, bus: nil,
accom: nil accom: nil,
seqnum: nil
} }
def performer_fixture(attrs \\ %{}) do def performer_fixture(attrs \\ %{}) do
@@ -78,6 +81,7 @@ defmodule Runosaari.RegistrationTest do
assert performer.date3 == true assert performer.date3 == true
assert performer.bus == true assert performer.bus == true
assert performer.accom == true assert performer.accom == true
assert performer.seqnum == 1
end end
test "create_performer/1 with invalid data returns error changeset" do test "create_performer/1 with invalid data returns error changeset" do
@@ -101,6 +105,7 @@ defmodule Runosaari.RegistrationTest do
assert performer.date3 == true assert performer.date3 == true
assert performer.bus == true assert performer.bus == true
assert performer.accom == true assert performer.accom == true
assert performer.seqnum == 2
end end
test "update_performer/2 with invalid data returns error changeset" do test "update_performer/2 with invalid data returns error changeset" do

View File

@@ -6,9 +6,19 @@ defmodule Runosaari.ScheduleTest do
describe "performances" do describe "performances" do
alias Runosaari.Schedule.Performance alias Runosaari.Schedule.Performance
@valid_attrs %{description: "some description", notes: "some notes", time: ~N[2010-04-17 14:00:00]} @valid_attrs %{
@update_attrs %{description: "some updated description", notes: "some updated notes", time: ~N[2011-05-18 15:01:01]} description: "some description",
@invalid_attrs %{description: nil, notes: nil, time: nil} notes: "some notes",
time: ~N[2010-04-17 14:00:00],
seqnum: 1
}
@update_attrs %{
description: "some updated description",
notes: "some updated notes",
time: ~N[2011-05-18 15:01:01],
seqnum: 2
}
@invalid_attrs %{description: nil, notes: nil, time: nil, seqnum: nil}
def performance_fixture(attrs \\ %{}) do def performance_fixture(attrs \\ %{}) do
{:ok, performance} = {:ok, performance} =
@@ -34,6 +44,7 @@ defmodule Runosaari.ScheduleTest do
assert performance.description == "some description" assert performance.description == "some description"
assert performance.notes == "some notes" assert performance.notes == "some notes"
assert performance.time == ~N[2010-04-17 14:00:00] assert performance.time == ~N[2010-04-17 14:00:00]
assert performance.seqnum == 1
end end
test "create_performance/1 with invalid data returns error changeset" do test "create_performance/1 with invalid data returns error changeset" do
@@ -42,15 +53,22 @@ defmodule Runosaari.ScheduleTest do
test "update_performance/2 with valid data updates the performance" do test "update_performance/2 with valid data updates the performance" do
performance = performance_fixture() performance = performance_fixture()
assert {:ok, %Performance{} = performance} = Schedule.update_performance(performance, @update_attrs)
assert {:ok, %Performance{} = performance} =
Schedule.update_performance(performance, @update_attrs)
assert performance.description == "some updated description" assert performance.description == "some updated description"
assert performance.notes == "some updated notes" assert performance.notes == "some updated notes"
assert performance.time == ~N[2011-05-18 15:01:01] assert performance.time == ~N[2011-05-18 15:01:01]
assert performance.seqnum == 2
end end
test "update_performance/2 with invalid data returns error changeset" do test "update_performance/2 with invalid data returns error changeset" do
performance = performance_fixture() performance = performance_fixture()
assert {:error, %Ecto.Changeset{}} = Schedule.update_performance(performance, @invalid_attrs)
assert {:error, %Ecto.Changeset{}} =
Schedule.update_performance(performance, @invalid_attrs)
assert performance == Schedule.get_performance!(performance.id) assert performance == Schedule.get_performance!(performance.id)
end end

View File

@@ -6,14 +6,16 @@ defmodule RunosaariWeb.PerformanceControllerTest do
@create_attrs %{ @create_attrs %{
description: "some description", description: "some description",
notes: "some notes", notes: "some notes",
time: ~N[2010-04-17 14:00:00] time: ~N[2010-04-17 14:00:00],
seqnum: 1
} }
@update_attrs %{ @update_attrs %{
description: "some updated description", description: "some updated description",
notes: "some updated notes", notes: "some updated notes",
time: ~N[2011-05-18 15:01:01] time: ~N[2011-05-18 15:01:01],
seqnum: 2
} }
@invalid_attrs %{description: nil, notes: nil, time: nil} @invalid_attrs %{description: nil, notes: nil, time: nil, seqnum: nil}
def fixture(:performance) do def fixture(:performance) do
{:ok, performance} = Schedule.create_performance(@create_attrs) {:ok, performance} = Schedule.create_performance(@create_attrs)
@@ -23,14 +25,14 @@ defmodule RunosaariWeb.PerformanceControllerTest do
describe "index" do describe "index" do
test "lists all performances", %{conn: conn} do test "lists all performances", %{conn: conn} do
conn = get(conn, Routes.performance_path(conn, :index)) conn = get(conn, Routes.performance_path(conn, :index))
assert html_response(conn, 200) =~ "Listing Performances" assert html_response(conn, 200) =~ "Ohjelma"
end end
end end
describe "new performance" do describe "new performance" do
test "renders form", %{conn: conn} do test "renders form", %{conn: conn} do
conn = get(conn, Routes.admin_performance_path(conn, :new)) conn = get(conn, Routes.admin_performance_path(conn, :new))
assert html_response(conn, 200) =~ "New Performance" assert html_response(conn, 200) =~ "Luo näytös"
end end
end end
@@ -42,12 +44,12 @@ defmodule RunosaariWeb.PerformanceControllerTest do
assert redirected_to(conn) == Routes.performance_path(conn, :show, id) assert redirected_to(conn) == Routes.performance_path(conn, :show, id)
conn = get(conn, Routes.performance_path(conn, :show, id)) conn = get(conn, Routes.performance_path(conn, :show, id))
assert html_response(conn, 200) =~ "Show Performance" assert html_response(conn, 200) =~ "Näytös"
end end
test "renders errors when data is invalid", %{conn: conn} do test "renders errors when data is invalid", %{conn: conn} do
conn = post(conn, Routes.admin_performance_path(conn, :create), performance: @invalid_attrs) conn = post(conn, Routes.admin_performance_path(conn, :create), performance: @invalid_attrs)
assert html_response(conn, 200) =~ "New Performance" assert html_response(conn, 200) =~ "Luo näytös"
end end
end end
@@ -56,7 +58,7 @@ defmodule RunosaariWeb.PerformanceControllerTest do
test "renders form for editing chosen performance", %{conn: conn, performance: performance} do test "renders form for editing chosen performance", %{conn: conn, performance: performance} do
conn = get(conn, Routes.admin_performance_path(conn, :edit, performance)) conn = get(conn, Routes.admin_performance_path(conn, :edit, performance))
assert html_response(conn, 200) =~ "Edit Performance" assert html_response(conn, 200) =~ "Muokkaa näytöstä"
end end
end end
@@ -81,7 +83,7 @@ defmodule RunosaariWeb.PerformanceControllerTest do
performance: @invalid_attrs performance: @invalid_attrs
) )
assert html_response(conn, 200) =~ "Edit Performance" assert html_response(conn, 200) =~ "Muokkaa näytöstä"
end end
end end

View File

@@ -14,7 +14,8 @@ defmodule RunosaariWeb.PerformerControllerTest do
date2: true, date2: true,
date3: true, date3: true,
bus: true, bus: true,
accom: true accom: true,
seqnum: 1
} }
@update_attrs %{ @update_attrs %{
confirmed: false, confirmed: false,
@@ -27,7 +28,8 @@ defmodule RunosaariWeb.PerformerControllerTest do
date2: true, date2: true,
date3: true, date3: true,
bus: true, bus: true,
accom: true accom: true,
seqnum: 2
} }
@invalid_attrs %{ @invalid_attrs %{
@@ -41,7 +43,8 @@ defmodule RunosaariWeb.PerformerControllerTest do
date2: nil, date2: nil,
date3: nil, date3: nil,
bus: nil, bus: nil,
accom: nil accom: nil,
seqnum: nil
} }
def fixture(:performer) do def fixture(:performer) do
{:ok, performer} = Registration.create_performer(@create_attrs) {:ok, performer} = Registration.create_performer(@create_attrs)