Sha256: 49ebf6bf1a27a7af4435ce9ad00a0daf3568cccc67d9defb04d75b0b239059b1

Contents?: true

Size: 1.47 KB

Versions: 40

Compression:

Stored size: 1.47 KB

Contents

# frozen_string_literal: true

describe Rdkafka::Admin::CreateTopicHandle do
  let(:response) { 0 }

  subject do
    Rdkafka::Admin::CreateTopicHandle.new.tap do |handle|
      handle[:pending] = pending_handle
      handle[:response] = response
      handle[:error_string] = FFI::Pointer::NULL
      handle[:result_name] = FFI::MemoryPointer.from_string("my-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::Admin::CreateTopicHandle::WaitTimeoutError, /create topic/
    end

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

      it "should return a create topic report" do
        report = subject.wait

        expect(report.error_string).to eq(nil)
        expect(report.result_name).to eq("my-test-topic")
      end

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

        expect(report.error_string).to eq(nil)
        expect(report.result_name).to eq("my-test-topic")
      end
    end
  end

  describe "#raise_error" do
    let(:pending_handle) { false }

    before { subject[:response] = -1 }

    it "should raise the appropriate error when there is an error" do
      expect {
        subject.raise_error
      }.to raise_exception(Rdkafka::RdkafkaError, /Unknown broker error \(unknown\)/)
    end
  end
end

Version data entries

40 entries across 40 versions & 1 rubygems

Version Path
karafka-rdkafka-0.19.0 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.18.1 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.18.0 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.18.0.rc1 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.17.6 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.17.5 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.17.4 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.17.3 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.17.2 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.17.2.rc1 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.17.1 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.17.1.beta1 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.17.0 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.13.10 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.14.11 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.15.2 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.16.1 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.16.0 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.16.0.rc1 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.15.0 spec/rdkafka/admin/create_topic_handle_spec.rb