Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecate use Plug.Test #1252

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,8 +284,9 @@ Plug ships with a `Plug.Test` module that makes testing your plugs easy. Here is
```elixir
defmodule MyPlugTest do
use ExUnit.Case, async: true
use Plug.Test

import Plug.Test
import Plug.Conn

@opts MyRouter.init([])

test "returns hello world" do
Expand Down
6 changes: 5 additions & 1 deletion lib/plug/test.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ defmodule Plug.Test do
This module can be used in your test cases, like this:

use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn

Using this module will:

Expand All @@ -22,6 +23,9 @@ defmodule Plug.Test do
"""

@doc false
@deprecated """
Please use `import Plug.Test` and `import Plug.Conn` directly instead.
"""
defmacro __using__(_) do
quote do
import Plug.Test
Expand Down
3 changes: 2 additions & 1 deletion test/plug/basic_auth_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Plug.BasicAuthTest do
use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn

import Plug.BasicAuth

Expand Down
3 changes: 2 additions & 1 deletion test/plug/builder_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ defmodule Plug.BuilderTest do
end

use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn

test "exports the init/1 function" do
assert Sample.init(:ok) == :ok
Expand Down
2 changes: 1 addition & 1 deletion test/plug/conn/wrapper_error_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule Plug.Conn.WrapperErrorTest do
use ExUnit.Case, async: true
use Plug.Test
import Plug.Test

test "reraise/3" do
conn = conn(:get, "/")
Expand Down
3 changes: 2 additions & 1 deletion test/plug/conn_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Plug.ConnTest do
use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn

alias Plug.Conn
alias Plug.ProcessStore
Expand Down
3 changes: 2 additions & 1 deletion test/plug/csrf_protection_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Plug.CSRFProtectionTest do
use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn

alias Plug.CSRFProtection
alias Plug.CSRFProtection.InvalidCSRFTokenError
Expand Down
3 changes: 2 additions & 1 deletion test/plug/debugger_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Plug.DebuggerTest do
use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn

import ExUnit.CaptureLog

Expand Down
3 changes: 2 additions & 1 deletion test/plug/error_handler_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Plug.ErrorHandlerTest do
use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn

defmodule ForbiddenError do
defexception plug_status: 403, message: "oops"
Expand Down
3 changes: 2 additions & 1 deletion test/plug/head_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Plug.HeadTest do
use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn

@opts Plug.Head.init([])

Expand Down
3 changes: 2 additions & 1 deletion test/plug/logger_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Plug.LoggerTest do
use ExUnit.Case
use Plug.Test
import Plug.Test
import Plug.Conn

import ExUnit.CaptureLog

Expand Down
3 changes: 2 additions & 1 deletion test/plug/method_override_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Plug.MethodOverrideTest do
use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn

def urlencoded_conn(method, body) do
method
Expand Down
3 changes: 2 additions & 1 deletion test/plug/parsers/json_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Plug.Parsers.JSONTest do
use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn

defmodule JSON do
def decode!("[1, 2, 3]") do
Expand Down
3 changes: 2 additions & 1 deletion test/plug/parsers_test.exs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
defmodule Plug.ParsersTest do
use ExUnit.Case, async: true

use Plug.Test
import Plug.Test
import Plug.Conn

defmodule BodyReader do
def read_body(conn, opts) do
Expand Down
3 changes: 2 additions & 1 deletion test/plug/request_id_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Plug.RequestIdTest do
use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn

defp call(conn, opts) do
Plug.RequestId.call(conn, Plug.RequestId.init(opts))
Expand Down
3 changes: 2 additions & 1 deletion test/plug/rewrite_on_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Plug.RewriteOnTest do
use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn

defp call(conn, rewrite) do
Plug.RewriteOn.call(conn, Plug.RewriteOn.init(rewrite))
Expand Down
3 changes: 2 additions & 1 deletion test/plug/router_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,8 @@ defmodule Plug.RouterTest do
end

use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn

test "dispatch root" do
conn = call(Sample, conn(:get, "/"))
Expand Down
3 changes: 2 additions & 1 deletion test/plug/session/cookie_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Plug.Session.CookieTest do
use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn

alias Plug.Session.COOKIE, as: CookieStore

Expand Down
3 changes: 2 additions & 1 deletion test/plug/session_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Plug.SessionTest do
use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn

alias Plug.ProcessStore
doctest Plug.Session.Store
Expand Down
3 changes: 2 additions & 1 deletion test/plug/ssl_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Plug.SSLTest do
use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn

describe "configure" do
import Plug.SSL, only: [configure: 1]
Expand Down
3 changes: 2 additions & 1 deletion test/plug/static_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule Plug.StaticTest do
use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn

@default_opts [
at: "/public",
Expand Down
2 changes: 1 addition & 1 deletion test/plug/telemetry_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Application.ensure_all_started(:telemetry)

defmodule Plug.TelemetryTest do
use ExUnit.Case, async: true
use Plug.Test
import Plug.Test

defmodule MyPlug do
use Plug.Builder
Expand Down
3 changes: 2 additions & 1 deletion test/plug_test.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule PlugTest do
use ExUnit.Case, async: true
use Plug.Test
import Plug.Test
import Plug.Conn

import ExUnit.CaptureLog

Expand Down