diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c4423b..9ab02e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,37 +16,40 @@ jobs: fail-fast: false matrix: include: - - pair: - elixir: "1.8.2" - otp: "21.3.8.17" - - pair: - elixir: "1.15.0" - otp: "25.3" + # Hard to test the oldest-supported version because rabbit_common and friends + # are a bit hard to get compatibility right for. However, we don't really need + # to do that here. + - elixir: "1.16" + otp: "26.2" + + # Latest-supported Elixir/OTP versions. + - elixir: "1.17.3" + otp: "27.1" lint: lint coverage: coverage steps: - name: Clone the repository - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Start Docker - run: docker-compose up --detach + run: docker compose up --detach - name: Install Erlang/OTP and Elixir uses: erlef/setup-beam@v1 with: - otp-version: ${{ matrix.pair.otp }} - elixir-version: ${{ matrix.pair.elixir }} + otp-version: ${{ matrix.otp }} + elixir-version: ${{ matrix.elixir }} - name: Cache Mix dependencies - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | deps _build key: | - ${{ runner.os }}-mix-${{ matrix.pair.elixir }}-${{ matrix.pair.otp }}-${{ hashFiles('**/mix.lock') }} + ${{ runner.os }}-mix-${{ matrix.elixir }}-${{ matrix.otp }}-${{ hashFiles('**/mix.lock') }} restore-keys: | - ${{ runner.os }}-mix-${{ matrix.pair.elixir }}-${{ matrix.pair.otp }}- + ${{ runner.os }}-mix-${{ matrix.elixir }}-${{ matrix.otp }}- - name: Fetch Mix dependencies run: mix deps.get @@ -59,9 +62,6 @@ jobs: run: mix deps.unlock --check-unused if: ${{ matrix.lint }} - - name: Compile Mix dependencies - run: mix deps.compile - - name: Compile code and check for warnings run: mix compile --warnings-as-errors if: ${{ matrix.lint }} diff --git a/docker-compose.yml b/docker-compose.yml index 14de096..896b742 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3' - services: rabbitmq: image: "rabbitmq:3.11.9-alpine" diff --git a/mix.exs b/mix.exs index 8b372d4..76d3b62 100644 --- a/mix.exs +++ b/mix.exs @@ -9,7 +9,7 @@ defmodule BroadwayRabbitMQ.MixProject do [ app: :broadway_rabbitmq, version: @version, - elixir: "~> 1.8", + elixir: "~> 1.13", name: "BroadwayRabbitMQ", description: @description, start_permanent: Mix.env() == :prod, diff --git a/test/broadway_rabbitmq/ampq_client_test.exs b/test/broadway_rabbitmq/ampq_client_test.exs index f3c86aa..193ad69 100644 --- a/test/broadway_rabbitmq/ampq_client_test.exs +++ b/test/broadway_rabbitmq/ampq_client_test.exs @@ -138,15 +138,15 @@ defmodule BroadwayRabbitMQ.AmqpClientTest do test ":queue is required" do assert AmqpClient.init([]) == - {:error, "required option :queue not found, received options: []"} + {:error, "required :queue option not found, received options: []"} assert AmqpClient.init(queue: nil) == - {:error, "expected :queue to be a string, got: nil"} + {:error, "invalid value for :queue option: expected string, got: nil"} end test ":queue should be a string" do assert AmqpClient.init(queue: :an_atom) == - {:error, "expected :queue to be a string, got: :an_atom"} + {:error, "invalid value for :queue option: expected string, got: :an_atom"} {:ok, config} = AmqpClient.init(queue: "my_queue") assert config.queue == "my_queue" @@ -165,9 +165,10 @@ defmodule BroadwayRabbitMQ.AmqpClientTest do {:ok, opts} = AmqpClient.init(queue: "queue", metadata: [:routing_key, :headers]) assert opts[:metadata] == [:routing_key, :headers] - message = - ~s(list element at position 0 in :metadata failed validation: expected "list element" ) <> - ~s(to be an atom, got: "routing_key") + message = """ + invalid list in :metadata option: invalid value for list element at position 0: expected \ + atom, got: "routing_key"\ + """ assert AmqpClient.init(queue: "queue", metadata: ["routing_key", :headers]) == {:error, message} @@ -177,18 +178,20 @@ defmodule BroadwayRabbitMQ.AmqpClientTest do {:ok, opts} = AmqpClient.init(queue: "queue", bindings: [{"my-exchange", [arguments: []]}]) assert opts[:bindings] == [{"my-exchange", [arguments: []]}] - message = - ~s(list element at position 0 in :bindings failed validation: expected binding to be ) <> - ~s(a {exchange, opts} tuple, got: :something) + message = """ + invalid list in :bindings option: invalid value for list element at position 0: \ + expected binding to be a {exchange, opts} tuple, got: :something\ + """ assert AmqpClient.init(queue: "queue", bindings: [:something, :else]) == {:error, message} end test ":bindings with invalid binding options" do - message = - "list element at position 0 in :bindings failed validation: unknown options " <> - "[:invalid], valid options are: [:routing_key, :arguments]" + message = """ + invalid list in :bindings option: invalid value for list element at position 0: \ + unknown options [:invalid], valid options are: [:routing_key, :arguments]\ + """ assert AmqpClient.init(queue: "queue", bindings: [{"my-exchange", [invalid: true]}]) == {:error, message} diff --git a/test/broadway_rabbitmq/producer_test.exs b/test/broadway_rabbitmq/producer_test.exs index 11997f0..0d494cc 100644 --- a/test/broadway_rabbitmq/producer_test.exs +++ b/test/broadway_rabbitmq/producer_test.exs @@ -230,27 +230,21 @@ defmodule BroadwayRabbitMQ.ProducerTest do end test "raise an ArgumentError with proper message when client options are invalid" do - assert_raise( - ArgumentError, - "invalid options given to BroadwayRabbitMQ.AmqpClient.init/1, expected :queue to be a string, got: nil", - fn -> - BroadwayRabbitMQ.Producer.init(queue: nil, on_failure: :reject_and_requeue) - end - ) + message = ~r/invalid value for :queue option: expected string, got: nil/ + + assert_raise ArgumentError, message, fn -> + BroadwayRabbitMQ.Producer.init(queue: nil, on_failure: :reject_and_requeue) + end end test "raise an ArgumentError with proper message when backoff options are invalid" do - assert_raise( - ArgumentError, - ~r/expected :backoff_type to be one of/, - fn -> - BroadwayRabbitMQ.Producer.init( - queue: "test", - backoff_type: :unknown_type, - on_failure: :reject_and_requeue - ) - end - ) + assert_raise ArgumentError, ~r/invalid value for :backoff_type/, fn -> + BroadwayRabbitMQ.Producer.init( + queue: "test", + backoff_type: :unknown_type, + on_failure: :reject_and_requeue + ) + end end test "prints a deprecation warning when :on_failure is not specified" do