From 3bb88f3d92ad8c8520ae8c572f4b05bf99db8c10 Mon Sep 17 00:00:00 2001 From: Simone Cottini Date: Fri, 27 Sep 2024 16:11:29 +0200 Subject: [PATCH] Reformat --- lib/amqp/connection.ex | 10 +++++++--- test/connection_test.exs | 14 +++++++------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/lib/amqp/connection.ex b/lib/amqp/connection.ex index 8a6ba4a..905d5ed 100644 --- a/lib/amqp/connection.ex +++ b/lib/amqp/connection.ex @@ -14,7 +14,7 @@ defmodule Amqpx.Connection do username: "guest", password: "guest", virtual_host: "/", - host: 'localhost', + host: ~c"localhost", port: 5672, channel_max: 0, frame_max: 0, @@ -210,7 +210,9 @@ defmodule Amqpx.Connection do {:ok, pid} -> IO.inspect("Connection opened to: #{ip}") {:halt, {:ok, %Connection{pid: pid}}} - error -> {:cont, error} + + error -> + {:cont, error} end end) end @@ -233,7 +235,9 @@ defmodule Amqpx.Connection do case :inet.gethostbyname(host) do {:ok, {:hostent, _, _, _, _, ips}} -> ips |> Enum.map(&:inet.ntoa/1) |> Enum.dedup() - _ -> [host] + + _ -> + [host] end end end diff --git a/test/connection_test.exs b/test/connection_test.exs index 6f3db71..f9af41d 100644 --- a/test/connection_test.exs +++ b/test/connection_test.exs @@ -23,7 +23,7 @@ defmodule ConnectionTest do Connection.open( username: "amqpx", password: "amqpx", - host: 'rabbit', + host: ~c"rabbit", obfuscate_password: @obfuscate_password ) @@ -38,7 +38,7 @@ defmodule ConnectionTest do test "open connection using both uri and options" do assert {:ok, conn} = Connection.open("amqp://amqpx:amqpx@nonexistent:5672", - host: 'rabbit', + host: ~c"rabbit", obfuscate_password: @obfuscate_password ) @@ -48,7 +48,7 @@ defmodule ConnectionTest do test "open connection with uri, name, and options" do assert {:ok, conn} = Connection.open("amqp://amqpx:amqpx@nonexistent:5672", "my-connection", - host: 'rabbit', + host: ~c"rabbit", obfuscate_password: @obfuscate_password ) @@ -66,21 +66,21 @@ defmodule ConnectionTest do assert params[:username] == "amqpx" assert params[:password] == "amqpx" - assert params[:host] == 'rabbit' + assert params[:host] == ~c"rabbit" end describe "ip resolution" do test "localhost is resolved as 127.0.0.1" do - assert ['127.0.0.1'] = Connection.resolve_ips('localhost') + assert [~c"127.0.0.1"] = Connection.resolve_ips(~c"localhost") end test "rabbit can be resolved into an ip" do - assert [ip] = Connection.resolve_ips('rabbit') + assert [ip] = Connection.resolve_ips(~c"rabbit") assert {:ok, _} = :inet.parse_address(ip) end test "unknown host will not be resolved" do - assert ['nonexistent'] = Connection.resolve_ips('nonexistent') + assert [~c"nonexistent"] = Connection.resolve_ips(~c"nonexistent") end end end