Sha256: 9e0da0363a22d9867230aaee9db3bedb55244942623523eb6b1d79d89f23fc1f

Contents?: true

Size: 1.42 KB

Versions: 20

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

require "spec_helper"

describe Rdkafka::Consumer::Partition do
  let(:offset) { 100 }
  let(:err) { 0 }
  subject { Rdkafka::Consumer::Partition.new(1, offset, err) }

  it "should have a partition" do
    expect(subject.partition).to eq 1
  end

  it "should have an offset" do
    expect(subject.offset).to eq 100
  end

  it "should have an err code" do
    expect(subject.err).to eq 0
  end

  describe "#to_s" do
    it "should return a human readable representation" do
      expect(subject.to_s).to eq "<Partition 1 offset=100>"
    end
  end

  describe "#inspect" do
    it "should return a human readable representation" do
      expect(subject.to_s).to eq "<Partition 1 offset=100>"
    end

    context "without offset" do
      let(:offset) { nil }

      it "should return a human readable representation" do
        expect(subject.to_s).to eq "<Partition 1>"
      end
    end

    context "with err code" do
      let(:err) { 1 }

      it "should return a human readable representation" do
        expect(subject.to_s).to eq "<Partition 1 offset=100 err=1>"
      end
    end
  end

  describe "#==" do
    it "should equal another partition with the same content" do
      expect(subject).to eq Rdkafka::Consumer::Partition.new(1, 100)
    end

    it "should not equal another partition with different content" do
      expect(subject).not_to eq Rdkafka::Consumer::Partition.new(2, 101)
    end
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
rdkafka-0.13.1 spec/rdkafka/consumer/partition_spec.rb
karafka-rdkafka-0.13.8 spec/rdkafka/consumer/partition_spec.rb
karafka-rdkafka-0.13.7 spec/rdkafka/consumer/partition_spec.rb
karafka-rdkafka-0.13.6 spec/rdkafka/consumer/partition_spec.rb
karafka-rdkafka-0.13.5 spec/rdkafka/consumer/partition_spec.rb
karafka-rdkafka-0.13.4 spec/rdkafka/consumer/partition_spec.rb
rdkafka-0.13.0 spec/rdkafka/consumer/partition_spec.rb
karafka-rdkafka-0.13.3 spec/rdkafka/consumer/partition_spec.rb
karafka-rdkafka-0.13.2 spec/rdkafka/consumer/partition_spec.rb
karafka-rdkafka-0.13.1 spec/rdkafka/consumer/partition_spec.rb
rdkafka-0.13.0.beta.8 spec/rdkafka/consumer/partition_spec.rb
karafka-rdkafka-0.13.0 spec/rdkafka/consumer/partition_spec.rb
karafka-rdkafka-0.13.0.beta2 spec/rdkafka/consumer/partition_spec.rb
karafka-rdkafka-0.13.0.beta1 spec/rdkafka/consumer/partition_spec.rb
rdkafka-0.13.0.beta.7 spec/rdkafka/consumer/partition_spec.rb
rdkafka-0.13.0.beta.6 spec/rdkafka/consumer/partition_spec.rb
rdkafka-0.13.0.beta.5 spec/rdkafka/consumer/partition_spec.rb
rdkafka-0.13.0.beta.3 spec/rdkafka/consumer/partition_spec.rb
rdkafka-0.13.0.beta.2 spec/rdkafka/consumer/partition_spec.rb
rdkafka-0.13.0.beta.1 spec/rdkafka/consumer/partition_spec.rb