aboutsummaryrefslogtreecommitdiff
path: root/test/controllers
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--test/controllers/audio_file_controller_test.exs66
-rw-r--r--test/controllers/page_controller_test.exs8
2 files changed, 74 insertions, 0 deletions
diff --git a/test/controllers/audio_file_controller_test.exs b/test/controllers/audio_file_controller_test.exs
new file mode 100644
index 0000000..e1df494
--- /dev/null
+++ b/test/controllers/audio_file_controller_test.exs
@@ -0,0 +1,66 @@
+defmodule TheTranscriberBackend.AudioFileControllerTest do
+ use TheTranscriberBackend.ConnCase
+
+ alias TheTranscriberBackend.AudioFile
+ @valid_attrs %{audio_duration: "some content", audio_path: "some content", transcription_file_path: "some content"}
+ @invalid_attrs %{}
+
+ test "lists all entries on index", %{conn: conn} do
+ conn = get conn, audio_file_path(conn, :index)
+ assert html_response(conn, 200) =~ "Listing audio file"
+ end
+
+ test "renders form for new resources", %{conn: conn} do
+ conn = get conn, audio_file_path(conn, :new)
+ assert html_response(conn, 200) =~ "New audio file"
+ end
+
+ test "creates resource and redirects when data is valid", %{conn: conn} do
+ conn = post conn, audio_file_path(conn, :create), audio_file: @valid_attrs
+ assert redirected_to(conn) == audio_file_path(conn, :index)
+ assert Repo.get_by(AudioFile, @valid_attrs)
+ end
+
+ test "does not create resource and renders errors when data is invalid", %{conn: conn} do
+ conn = post conn, audio_file_path(conn, :create), audio_file: @invalid_attrs
+ assert html_response(conn, 200) =~ "New audio file"
+ end
+
+ test "shows chosen resource", %{conn: conn} do
+ audio_file = Repo.insert! %AudioFile{}
+ conn = get conn, audio_file_path(conn, :show, audio_file)
+ assert html_response(conn, 200) =~ "Show audio file"
+ end
+
+ test "renders page not found when id is nonexistent", %{conn: conn} do
+ assert_error_sent 404, fn ->
+ get conn, audio_file_path(conn, :show, -1)
+ end
+ end
+
+ test "renders form for editing chosen resource", %{conn: conn} do
+ audio_file = Repo.insert! %AudioFile{}
+ conn = get conn, audio_file_path(conn, :edit, audio_file)
+ assert html_response(conn, 200) =~ "Edit audio file"
+ end
+
+ test "updates chosen resource and redirects when data is valid", %{conn: conn} do
+ audio_file = Repo.insert! %AudioFile{}
+ conn = put conn, audio_file_path(conn, :update, audio_file), audio_file: @valid_attrs
+ assert redirected_to(conn) == audio_file_path(conn, :show, audio_file)
+ assert Repo.get_by(AudioFile, @valid_attrs)
+ end
+
+ test "does not update chosen resource and renders errors when data is invalid", %{conn: conn} do
+ audio_file = Repo.insert! %AudioFile{}
+ conn = put conn, audio_file_path(conn, :update, audio_file), audio_file: @invalid_attrs
+ assert html_response(conn, 200) =~ "Edit audio file"
+ end
+
+ test "deletes chosen resource", %{conn: conn} do
+ audio_file = Repo.insert! %AudioFile{}
+ conn = delete conn, audio_file_path(conn, :delete, audio_file)
+ assert redirected_to(conn) == audio_file_path(conn, :index)
+ refute Repo.get(AudioFile, audio_file.id)
+ end
+end
diff --git a/test/controllers/page_controller_test.exs b/test/controllers/page_controller_test.exs
new file mode 100644
index 0000000..22c052d
--- /dev/null
+++ b/test/controllers/page_controller_test.exs
@@ -0,0 +1,8 @@
+defmodule TheTranscriberBackend.PageControllerTest do
+ use TheTranscriberBackend.ConnCase
+
+ test "GET /", %{conn: conn} do
+ conn = get conn, "/"
+ assert html_response(conn, 200) =~ "Welcome to Phoenix!"
+ end
+end