Sha256: ff72a027afbf3a1dd227949a20e90628a50a059e50360754c0c3a88d48ad5dd1

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

RSpec.describe KafkaCommand::ConsumerGroupPartition do
  let(:group_id)     { "group-#{SecureRandom.hex(12)}" }
  let(:topic_name)   { "test-#{SecureRandom.hex(12)}" }
  let(:lag)          { 1 }
  let(:offset)       { 200 }
  let(:partition_id) { 1 }

  let(:consumer_group_partition_) do
    described_class.new(
      group_id: group_id,
      lag: lag,
      offset: offset,
      topic_name: topic_name,
      partition_id: partition_id
    )
  end

  describe '#new' do
    it 'creates a new Kafka::ConsumerGroupPartition with attributes' do
      expect(consumer_group_partition_.lag).to eq(lag)
      expect(consumer_group_partition_.group_id).to eq(group_id)
      expect(consumer_group_partition_.topic_name).to eq(topic_name)
      expect(consumer_group_partition_.offset).to eq(offset)
      expect(consumer_group_partition_.partition_id).to eq(partition_id)
    end
  end

  describe '#as_json' do
    let(:expected_json) do
      {
        lag: lag,
        offset: offset,
        partition_id: partition_id
      }
    end

    it 'returns the expected payload' do
      expect(consumer_group_partition_.as_json).to eq(expected_json)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
kafka_command-0.0.3 spec/models/kafka_command/consumer_group_partition_spec.rb
kafka_command-0.0.2 spec/models/kafka_command/consumer_group_partition_spec.rb
kafka_command-0.0.1 spec/models/kafka_command/consumer_group_partition_spec.rb