Sha256: 1ae9626aeff5bdf3b1e0fa0b20c77ecf80a89e10b1aaa7613494b2d39dfd388a

Contents?: true

Size: 1.42 KB

Versions: 17

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

require "spec_helper"

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

  subject do
    Rdkafka::Admin::DeleteTopicHandle.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::DeleteTopicHandle::WaitTimeoutError, /delete topic/
    end

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

      it "should return a delete 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

17 entries across 17 versions & 2 rubygems

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