Skip to content

Commit

Permalink
Use charlist sigil
Browse files Browse the repository at this point in the history
  • Loading branch information
ono committed Mar 3, 2024
1 parent df87835 commit 2635196
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/amqp/connection.ex
Expand Up @@ -227,7 +227,7 @@ defmodule AMQP.Connection do
username: Keyword.get(options, :username, "guest"),
password: Keyword.get(options, :password, "guest"),
virtual_host: Keyword.get(options, :virtual_host, "/"),
host: Keyword.get(options, :host, 'localhost') |> to_charlist(),
host: Keyword.get(options, :host, ~c"localhost") |> to_charlist(),
port: Keyword.get(options, :port, :undefined) |> normalize_int_opt(),
channel_max: Keyword.get(options, :channel_max, 0) |> normalize_int_opt(),
frame_max: Keyword.get(options, :frame_max, 0) |> normalize_int_opt(),
Expand Down
12 changes: 6 additions & 6 deletions test/connection_test.exs
Expand Up @@ -19,7 +19,7 @@ defmodule ConnectionTest do
end

test "open connection with host as char list" do
assert {:ok, conn} = Connection.open(host: 'localhost')
assert {:ok, conn} = Connection.open(host: ~c"localhost")
assert :ok = Connection.close(conn)
end

Expand All @@ -29,14 +29,14 @@ defmodule ConnectionTest do
end

test "open connection using both uri and options" do
assert {:ok, conn} = Connection.open("amqp://nonexistent:5672", host: 'localhost')
assert {:ok, conn} = Connection.open("amqp://nonexistent:5672", host: ~c"localhost")
assert :ok = Connection.close(conn)
end

test "open connection with uri, port as an integer, and options " do
assert {:ok, conn} =
Connection.open("amqp://nonexistent",
host: 'localhost',
host: ~c"localhost",
port: 5672
)

Expand All @@ -46,7 +46,7 @@ defmodule ConnectionTest do
test "open connection with uri, port as a string, and options" do
assert {:ok, conn} =
Connection.open("amqp://nonexistent",
host: 'localhost',
host: ~c"localhost",
port: "5672"
)

Expand All @@ -61,7 +61,7 @@ defmodule ConnectionTest do

test "open connection with uri, name, and options (deprecated but still supported)" do
assert {:ok, conn} =
Connection.open("amqp://nonexistent:5672", "my-connection", host: 'localhost')
Connection.open("amqp://nonexistent:5672", "my-connection", host: ~c"localhost")

Check warning on line 64 in test/connection_test.exs

View workflow job for this annotation

GitHub Actions / Test (Elixir 1.15.x | Erlang/OTP 26.x)

AMQP.Connection.open/3 is deprecated. Use :name in open/2 instead

Check warning on line 64 in test/connection_test.exs

View workflow job for this annotation

GitHub Actions / Test (Elixir 1.14.5 | Erlang/OTP 26.x)

AMQP.Connection.open/3 is deprecated. Use :name in open/2 instead

Check warning on line 64 in test/connection_test.exs

View workflow job for this annotation

GitHub Actions / Test (Elixir 1.13.4 | Erlang/OTP 25.x)

AMQP.Connection.open/3 is deprecated. Use :name in open/2 instead

Check warning on line 64 in test/connection_test.exs

View workflow job for this annotation

GitHub Actions / Test (Elixir 1.12.3 | Erlang/OTP 24.x)

AMQP.Connection.open/3 is deprecated. Use :name in open/2 instead

assert :ok = Connection.close(conn)
end
Expand All @@ -74,7 +74,7 @@ defmodule ConnectionTest do

assert params[:username] == "me"
assert params[:password] == "bar"
assert params[:host] == 'amqp.test.com'
assert params[:host] == ~c"amqp.test.com"
end

defp get_connection_name(conn) do
Expand Down

0 comments on commit 2635196

Please sign in to comment.