Sha256: ff706e375069c462015ee6edb34b20a67ec42aa3b040ac0013d5d36cedaea26e

Contents?: true

Size: 1.25 KB

Versions: 4

Compression:

Stored size: 1.25 KB

Contents

require_relative "../../../spec/es_spec_helper"

describe "outputs/elasticsearch" do
  describe "http client create" do
    require "logstash/outputs/elasticsearch"
    require "elasticsearch"

    let(:options) {
      {
        "index" => "my-index",
        "hosts" => "localhost",
        "path" => "some-path"
      }
    }

    let(:eso) {LogStash::Outputs::ElasticSearch.new(options)}

    let(:manticore_host) {
      eso.client.send(:client).transport.options[:hosts].first
    }

    around(:each) do |block|
      thread = eso.register
      block.call()
      thread.kill()
    end

    describe "with path" do
      it "should properly create a URI with the path" do
        expect(eso.path).to eql(options["path"])
      end


      it "should properly set the path on the HTTP client adding slashes" do
        expect(manticore_host).to include("/" + options["path"] + "/")
      end

      context "with extra slashes" do
        let(:path) { "/slashed-path/ "}
        let(:eso) {
          LogStash::Outputs::ElasticSearch.new(options.merge("path" => "/some-path/"))
        }

        it "should properly set the path on the HTTP client without adding slashes" do
          expect(manticore_host).to include(options["path"])
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
logstash-output-elasticsearch-2.0.0.beta6-java spec/unit/outputs/elasticsearch_spec.rb
logstash-output-elasticsearch-2.0.0.beta5-java spec/unit/outputs/elasticsearch_spec.rb
logstash-output-elasticsearch-2.0.0.beta4-java spec/unit/outputs/elasticsearch_spec.rb
logstash-output-elasticsearch-2.0.0.pre.beta2-java spec/unit/outputs/elasticsearch_spec.rb