summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/farside_test.exs93
-rw-r--r--test/test_helper.exs1
2 files changed, 0 insertions, 94 deletions
diff --git a/test/farside_test.exs b/test/farside_test.exs
deleted file mode 100644
index b036fdc..0000000
--- a/test/farside_test.exs
+++ /dev/null
@@ -1,93 +0,0 @@
-defmodule FarsideTest do
-
- use ExUnit.Case
- use Plug.Test
-
- alias Farside.Router
-
- @opts Router.init([])
-
- def test_conn(path) do
- :timer.sleep(1000)
-
- :get
- |> conn(path, "")
- |> Router.call(@opts)
- end
-
- test "throttle" do
- first_conn =
- :get
- |> conn("/", "")
- |> Router.call(@opts)
-
- first_redirect = elem(List.last(first_conn.resp_headers), 1)
-
- throttled_conn =
- :get
- |> conn("/", "")
- |> Router.call(@opts)
-
- throttled_redirect = elem(List.last(first_conn.resp_headers), 1)
-
- assert throttled_conn.state == :sent
- assert throttled_redirect == first_redirect
- end
-
- test "/" do
- conn = test_conn("/")
- assert conn.state == :sent
- assert conn.status == 200
- end
-
- test "/:service" do
- services_json = Application.fetch_env!(:farside, :services_json)
- {:ok, file} = File.read(services_json)
- {:ok, service_list} = Jason.decode(file)
-
- service_names =
- Enum.map(
- service_list,
- fn service -> service["type"] end
- )
-
- IO.puts("")
-
- service_names |>
- Enum.filter(fn service_name -> service_name != "nitter" end) |>
- Enum.map(fn service_name ->
- conn = test_conn("/#{service_name}")
- first_redirect = elem(List.last(conn.resp_headers), 1)
-
- IO.puts(" /#{service_name} (#1) -- #{first_redirect}")
- assert conn.state == :set
- assert conn.status == 302
-
- conn = test_conn("/#{service_name}")
- second_redirect = elem(List.last(conn.resp_headers), 1)
-
- IO.puts(" /#{service_name} (#2) -- #{second_redirect}")
- assert conn.state == :set
- assert conn.status == 302
- assert first_redirect != second_redirect
- end)
- end
-
- test "/https://..." do
- parent_service = "https://www.youtube.com"
- parent_path = "watch?v=dQw4w9WgXcQ"
- conn = test_conn("/#{parent_service}/#{parent_path}")
-
- redirect = elem(List.last(conn.resp_headers), 1)
-
- IO.puts("")
- IO.puts(" /#{parent_service}/#{parent_path}")
- IO.puts(" redirected to")
- IO.puts(" #{redirect}")
-
- assert conn.state == :set
- assert conn.status == 302
- assert redirect =~ parent_path
- assert !(redirect =~ parent_service)
- end
-end
diff --git a/test/test_helper.exs b/test/test_helper.exs
deleted file mode 100644
index 869559e..0000000
--- a/test/test_helper.exs
+++ /dev/null
@@ -1 +0,0 @@
-ExUnit.start()