Sha256: ec77575c5aba49294ffea21ff293ef1181dc805f7b31e5149110054c509f9c24

Contents?: true

Size: 1.76 KB

Versions: 5

Compression:

Stored size: 1.76 KB

Contents

require 'spec_helper'

describe do
  let(:driver) {
    AWS.stub!
    Fluent::Test::InputTestDriver.new(Fluent::SQSInput).configure(config)
  }
  let(:instance) {driver.instance}

  describe 'config' do
    let(:config) {
      %[
         aws_key_id AWS_KEY_ID
         aws_sec_key AWS_SEC_KEY
         tag     TAG
         sqs_url SQS_URL
      ]
    }
    
    context do
      subject {instance.aws_key_id}
      it{should == 'AWS_KEY_ID'}
    end

    context do
      subject {instance.aws_sec_key}
      it{should == 'AWS_SEC_KEY'}
    end

    context do
      subject {instance.tag}
      it{should == 'TAG'}
    end

    context do
      subject {instance.sqs_url}
      it{should == 'SQS_URL'}
    end

    context do
      subject {instance.receive_interval}
      it{should == 1}
    end
  end
  
  describe 'emit' do
    let(:message) do
      { :body => 'body',
        :handle => 'handle',
        :id => 'id',
        :md5 => 'md5',
        :url => 'url',
        :sender_id => 'sender_id'
      }
    end
    let(:emmits) {
      stub(Time).now {0}

      class AWS::SQS::Queue
        def receive_message
          yield OpenStruct.new(
            { :body => 'body',
              :handle => 'handle',
              :id => 'id',
              :md5 => 'md5',
              :queue => OpenStruct.new(:url => 'url'),
              :sender_id => 'sender_id',
              :sent_at => 0
            })
        end
      end
      d = driver
      d.run do
        sleep 2
      end
      
      d.emits
    }

    context do
      let(:config) {
        %[
           aws_key_id AWS_KEY_ID
           aws_sec_key AWS_SEC_KEY
           tag     TAG
           sqs_url SQS_URL
        ]
      }

      subject {emmits.first}
      it{should ==  ['TAG', 0, message]}
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
fluent-plugin-sqs-1.3.2 spec/lib/fluent/plugin/in_sqs_spec.rb
fluent-plugin-sqs-1.3.1 spec/lib/fluent/plugin/in_sqs_spec.rb
fluent-plugin-sqs-1.2.2 spec/lib/fluent/plugin/in_sqs_spec.rb
fluent-plugin-sqs-1.2.1 spec/lib/fluent/plugin/in_sqs_spec.rb
fluent-plugin-sqs-1.2.0 spec/lib/fluent/plugin/in_sqs_spec.rb