Sha256: e430ab524d66ef6e1f94194a6d7d4a788b0854d63a83468a00e5845ef4101701

Contents?: true

Size: 1.27 KB

Versions: 16

Compression:

Stored size: 1.27 KB

Contents

# frozen_string_literal: true

require "spec_helper"

describe Rdkafka::Producer::DeliveryHandle do
  let(:response) { 0 }

  subject do
    Rdkafka::Producer::DeliveryHandle.new.tap do |handle|
      handle[:pending] = pending_handle
      handle[:response] = response
      handle[:partition] = 2
      handle[:offset] = 100
      handle[:topic_name] = FFI::MemoryPointer.from_string("produce_test_topic")
    end
  end

  describe "#wait" do
    let(:pending_handle) { true }

    it "should wait until the timeout and then raise an error" do
      expect {
        subject.wait(max_wait_timeout: 0.1)
      }.to raise_error Rdkafka::Producer::DeliveryHandle::WaitTimeoutError, /delivery/
    end

    context "when not pending anymore and no error" do
      let(:pending_handle) { false }

      it "should return a delivery report" do
        report = subject.wait

        expect(report.partition).to eq(2)
        expect(report.offset).to eq(100)
        expect(report.topic_name).to eq("produce_test_topic")
      end

      it "should wait without a timeout" do
        report = subject.wait(max_wait_timeout: nil)

        expect(report.partition).to eq(2)
        expect(report.offset).to eq(100)
        expect(report.topic_name).to eq("produce_test_topic")
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
rdkafka-0.13.1 spec/rdkafka/producer/delivery_handle_spec.rb
karafka-rdkafka-0.13.4 spec/rdkafka/producer/delivery_handle_spec.rb
rdkafka-0.13.0 spec/rdkafka/producer/delivery_handle_spec.rb
karafka-rdkafka-0.13.3 spec/rdkafka/producer/delivery_handle_spec.rb
karafka-rdkafka-0.13.2 spec/rdkafka/producer/delivery_handle_spec.rb
karafka-rdkafka-0.13.1 spec/rdkafka/producer/delivery_handle_spec.rb
rdkafka-0.13.0.beta.8 spec/rdkafka/producer/delivery_handle_spec.rb
karafka-rdkafka-0.13.0 spec/rdkafka/producer/delivery_handle_spec.rb
karafka-rdkafka-0.13.0.beta2 spec/rdkafka/producer/delivery_handle_spec.rb
karafka-rdkafka-0.13.0.beta1 spec/rdkafka/producer/delivery_handle_spec.rb
rdkafka-0.13.0.beta.7 spec/rdkafka/producer/delivery_handle_spec.rb
rdkafka-0.13.0.beta.6 spec/rdkafka/producer/delivery_handle_spec.rb
rdkafka-0.13.0.beta.5 spec/rdkafka/producer/delivery_handle_spec.rb
rdkafka-0.13.0.beta.3 spec/rdkafka/producer/delivery_handle_spec.rb
rdkafka-0.13.0.beta.2 spec/rdkafka/producer/delivery_handle_spec.rb
rdkafka-0.13.0.beta.1 spec/rdkafka/producer/delivery_handle_spec.rb