Skip to content

Commit

Permalink
integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
ignaciogoldchluk-yolo committed Aug 7, 2024
1 parent c4b83d7 commit 078338d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 2 deletions.
3 changes: 2 additions & 1 deletion compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
services:
rabbitmq:
image: "rabbitmq:alpine"
image: "rabbitmq:3.12-management-alpine"
ports:
- "5672:5672"
- "15672:15672"
15 changes: 14 additions & 1 deletion config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,20 @@ config :coney,
},
workers: [
FakeConsumer
]
],
topology: %{
exchanges: [{:topic, "exchange", durable: false}],
queues: %{
"queue" => %{
options: [
durable: false
],
bindings: [
[exchange: "exchange", options: [routing_key: "queue"]]
]
}
}
}

config :logger, level: :info

Expand Down
16 changes: 16 additions & 0 deletions test/lib/coney/coney_test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
defmodule Coney.ConeyTest do
use ExUnit.Case
use AMQP

describe "publish/2" do
test "consumes a message" do
{:ok, connection} = AMQP.Connection.open(Application.get_env(:coney, :settings)[:url])

{:ok, channel} = AMQP.Channel.open(connection)

assert :ok == AMQP.Basic.publish(channel, "exchange", "queue", "message", mandatory: true)

refute 0 == AMQP.Queue.consumer_count(channel, "queue")
end
end
end
1 change: 1 addition & 0 deletions test/support/fake_consumer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ defmodule FakeConsumer do
:reject -> :reject
:reply -> {:reply, :data}
:exception -> raise "Exception happen"
_other -> :ok
end
end

Expand Down

0 comments on commit 078338d

Please sign in to comment.