Sha256: 675a7e9144f81a07ba8b6e079dcd6b8313eb14c0593b6335c8634d0f7ca06773

Contents?: true

Size: 908 Bytes

Versions: 7

Compression:

Stored size: 908 Bytes

Contents

require_relative '../test_helper'

class ClientAdapterTest < Minitest::Test
  StubResponse = Struct.new(:error_code, :error_message)

  class EvenRecordsAreErrors < Telekinesis::Aws::ClientAdapter
    def do_put_records(stream, items)
      items.each_with_index.map do |_, idx|
        err, message = idx.even? ? ["error-#{idx}", "message-#{idx}"] : [nil, nil]
        StubResponse.new(err, message)
      end
    end
  end

  context "ClientAdapter" do
    context "put_records" do
      setup do
        @client = EvenRecordsAreErrors.new(nil)
        @items = 10.times.map{|i| ["key-#{i}", "value-#{i}"]}
        @expected = 10.times.select{|i| i.even?}
                            .map{|i| ["key-#{i}", "value-#{i}", "error-#{i}", "message-#{i}"]}
      end

      should "zip error responses with records" do
        assert(@expected, @client.put_records('stream', @items))
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
telekinesis-3.2.1-java test/aws/test_client_adapter.rb
telekinesis-3.2.0-java test/aws/test_client_adapter.rb
telekinesis-3.1.1-java test/aws/test_client_adapter.rb
telekinesis-3.1.0-java test/aws/test_client_adapter.rb
telekinesis-3.0.0-java test/aws/test_client_adapter.rb
telekinesis-2.0.1-java test/aws/test_client_adapter.rb
telekinesis-2.0.0-java test/aws/test_client_adapter.rb