From 3f4aac137fd1caf5a15953b43d8785966ab0e021 Mon Sep 17 00:00:00 2001 From: Brad Hanks Date: Wed, 10 Apr 2024 01:28:54 -0600 Subject: [PATCH] Address Elixir 1.16 compilation warnings (#139) --- config/config.exs | 2 +- lib/bypass/utils.ex | 12 +++++------- test/bypass_test.exs | 4 ++-- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/config/config.exs b/config/config.exs index a1625b8..b28243c 100644 --- a/config/config.exs +++ b/config/config.exs @@ -1,6 +1,6 @@ # This file is responsible for configuring your application # and its dependencies with the aid of the Mix.Config module. -use Mix.Config +import Config config :bypass, test_framework: :ex_unit diff --git a/lib/bypass/utils.ex b/lib/bypass/utils.ex index 0c1f1a1..50674b0 100644 --- a/lib/bypass/utils.ex +++ b/lib/bypass/utils.ex @@ -3,16 +3,14 @@ defmodule Bypass.Utils do Application.load(:bypass) - if Application.get_env(:bypass, :enable_debug_log, false) do - defmacro debug_log(msg) do - quote bind_quoted: [msg: msg] do + defmacro debug_log(msg) do + quote bind_quoted: [msg: msg] do + if Application.get_env(:bypass, :enable_debug_log, false) do require Logger Logger.debug(["[bypass] ", msg]) + else + :ok end end - else - defmacro debug_log(_msg) do - :ok - end end end diff --git a/test/bypass_test.exs b/test/bypass_test.exs index 6f41000..7f247c8 100644 --- a/test/bypass_test.exs +++ b/test/bypass_test.exs @@ -541,7 +541,7 @@ defmodule BypassTest do end test "Bypass.verify_expectations! - with ESpec it will check if the expectations are being met" do - Mix.Config.persist(bypass: [test_framework: :espec]) + Application.put_all_env(bypass: [test_framework: :espec]) # Fail: no requests bypass = prepare_stubs() @@ -579,7 +579,7 @@ defmodule BypassTest do Bypass.verify_expectations!(bypass) end - Mix.Config.persist(bypass: [test_framework: :ex_unit]) + Application.put_all_env(bypass: [test_framework: :ex_unit]) end test "Bypass.open/1 raises when cannot start child" do