Sha256: 856f843926a4fadffc8ce54f5761ffb6d25a7cfffaae9836d1234ff1df2d0c79

Contents?: true

Size: 1.39 KB

Versions: 18

Compression:

Stored size: 1.39 KB

Contents

require "spec_helper"

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 }

    it "should raise the appropriate error" do
      expect {
        subject.raise_error
      }.to raise_exception(Rdkafka::RdkafkaError, /Success \(no_error\)/)
    end
  end
end

Version data entries

18 entries across 18 versions & 2 rubygems

Version Path
rdkafka-0.12.1 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.12.4 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.12.3 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.12.2 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.12.1 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.12.1.beta1 spec/rdkafka/admin/create_topic_handle_spec.rb
karafka-rdkafka-0.12.0 spec/rdkafka/admin/create_topic_handle_spec.rb
rdkafka-0.12.0 spec/rdkafka/admin/create_topic_handle_spec.rb
rdkafka-0.12.0.beta.4 spec/rdkafka/admin/create_topic_handle_spec.rb
rdkafka-0.12.0.beta.3 spec/rdkafka/admin/create_topic_handle_spec.rb
rdkafka-0.12.0.beta.2 spec/rdkafka/admin/create_topic_handle_spec.rb
rdkafka-0.12.0.beta.1 spec/rdkafka/admin/create_topic_handle_spec.rb
rdkafka-0.12.0.beta.0 spec/rdkafka/admin/create_topic_handle_spec.rb
rdkafka-0.11.1 spec/rdkafka/admin/create_topic_handle_spec.rb
rdkafka-0.11.0 spec/rdkafka/admin/create_topic_handle_spec.rb
rdkafka-0.10.0 spec/rdkafka/admin/create_topic_handle_spec.rb
rdkafka-0.9.0 spec/rdkafka/admin/create_topic_handle_spec.rb
rdkafka-0.8.1 spec/rdkafka/admin/create_topic_handle_spec.rb